LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2008, 03:59 AM   #1
vamsi_k
Member
 
Registered: Aug 2008
Posts: 66

Rep: Reputation: 18
1 linux box with 2 nic cards connecting 2 different networks


1 linux box with 2 nic cards should be able to connect between 2 networks. In order to run one linux box on 2 networks .

any corrections need in the following steps ?

Steps i follow are :

1 ) /etc/resolv.conf :
i will add 2 networks dns server IP's .
1 st network :
nameserver XXX.XXX.XXX.XXX - IP address of primary name server nameserver XXX.XXX.XXX.XXX - IP address of secondary name server

2 nd network :
nameserver XXX.XXX.XXX.XXX - IP address of primary name server nameserver XXX.XXX.XXX.XXX - IP address of secondary name server


2) /etc/hosts
I will add ips here.
1 st network IP :
XXX.XXX.XXX.XXX node-name
2 nd network IP :
XXX.XXX.XXX.XXX node-name

Assigning IP address :
In each file :
/etc/sysconfig/network-scripts/ifcfg-eth0
if 2 nic cards are in static
Static IP address configuration:
DEVICE=eth0
BOOTPROTO=static
BROADCAST=XXX.XXX.XXX.255
IPADDR=XXX.XXX.XXX.XXX
NETMASK=255.255.255.0
NETWORK=XXX.XXX.XXX.0
ONBOOT=yes - Will activate upon system boot

if 2 nic cards are in DHCP configuration :

If DHCP configuration :
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp

Configuring gateway address :

/etc/sysconfig/network

i will add :

NETWORKING=yes
HOSTNAME=my-hostname - Hostname is defined here and by command hostname FORWARD_IPV4=true - True for NAT firewall gateways and linux routers.
False for everyone else - desktops and servers.

GATEWAY="XXX.XXX.XXX.YYY" - Used if your network is connected to another network or the internet.
Static IP configuration. Gateway not defined here for DHCP client


Enable Forwarding :
Turn on IP forwarding to allow Linux computer to act as a gateway or router.
echo 1 > /proc/sys/net/ipv4/ip_forward

/etc/sysctl.conf
net.ipv4.ip_forward = 1

and
Special routing information may be specified :
In
/etc/sysconfig/static-routes
eth1 net XXX.XXX.XXX.0 netmask 255.255.255.0 gw XXX.XXX.XXX.XXX
or

Access ISP network identified by the network address and netmask using network interface card eth0:
route add -net 10.13.21.0 netmask 255.255.255.0 gw 192.168.10.254 eth0
Conversly: route del -net 10.13.21.0 netmask 255.255.255.0 gw 192.168.10.254 eth0

i same way i will add other other nic card to connect to local lan

next :
/etc/sysconfig/network-scripts/ifup to bring the various network interfaces on-line

In order for updated information in any of these files to take effect, one must issue the command: service network restart

Commands for starting and stopping TCP/IP network services on an interface :

Activate: /sbin/ifup eth0
(Also: ifconfig eth0 up - Note: Even if no IP address is assigned you can listen.) De-Activate: /sbin/ifdown eth0
(Also: ifconfig eth0 down)

Last edited by vamsi_k; 10-19-2008 at 04:01 AM.
 
Old 10-19-2008, 08:46 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
You really should tell us which distro you're using. Not all
distros do networking the with the same files. For example,
what you describe wouldn't work on my CLFS boxes. Might work
for whaterver distro you're using though. I do suspect that you'd need an /etc/sysconfig/network-scripts/ifcfg-eth1 for the second NIC.
 
Old 10-19-2008, 10:09 AM   #3
jejen
LQ Newbie
 
Registered: Mar 2005
Location: Jakarta
Distribution: RedHat 9
Posts: 3

Rep: Reputation: 0
i always use this configuration.
As example first network connect to eth0 the network id 192.168.1.0/24, the second network connect to eth1 the network id 192.168.2.0/24

so i just do :
ifconfig eth0 192.168.1.1
ifconfig eth1 192.168.2.1
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
echo 1 > /proc/sys/net/ipv4/ip_forward

And another computer at the first network assign 192.168.1.1 as their gateway and the second network assign 192.168.2.1 as their gateway.

it works for me. But you just make it permanent.
 
Old 10-20-2008, 12:21 AM   #4
vamsi_k
Member
 
Registered: Aug 2008
Posts: 66

Original Poster
Rep: Reputation: 18
Operating system : centos

thanks jejen. i will try the same.
 
Old 10-22-2008, 05:39 AM   #5
vamsi_k
Member
 
Registered: Aug 2008
Posts: 66

Original Poster
Rep: Reputation: 18
success. thanks jejen it worked.

Last edited by vamsi_k; 10-24-2008 at 08:01 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux box as a router between two networks LinuxLover Linux - Server 1 08-04-2007 01:25 AM
setting up routes - box with two nic cards josh_mcqueen Linux - Networking 2 07-21-2005 08:53 AM
Linux with multiple network cards, and bridging both networks together fuckyou Linux - Networking 2 07-10-2005 07:21 PM
Connecting Linux box to Internet through Windowx XP box over LAN pcd007 Linux - Networking 1 03-14-2004 09:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration