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) |
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. |
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. |
Operating system : centos
thanks jejen. i will try the same. |
success. thanks jejen it worked.
|
All times are GMT -5. The time now is 02:21 AM. |