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.
|