Operating System - Linux
1828584 Members
2397 Online
109982 Solutions
New Discussion

Re: linux dual nic interfaces configuration

 
SOLVED
Go to solution
jerry1
Super Advisor

linux dual nic interfaces configuration

I have two nic cards in Linux box.
One is production and one is for testing, or
future backup network.
How do I specify a network route for this
second testing interface. There are way too
many network config files to work with here.
Basically I have for working info:

ncc9t 10.40.191.51 255.255.255.224
ncc9 10.40.167.17 255.255.252.0
Default route 10.40.164.1

Need alternate route for network 10.40.191. ??


/etc/hosts
127.0.0.1 localhost.localdomain localhost
10.40.167.17 ncc9
10.40.191.51 ncc9t

netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.40.191.32 0.0.0.0 255.255.255.224 U 0 0 0 eth1
10.40.164.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 10.40.164.1 0.0.0.0 UG 0 0 0 eth0

/etc/sysconfig/network-scripts/ifcfg-eth1
# Intel Corporation 82545GM Gigabit Ethernet Controller
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.40.191.51
NETMASK=255.255.255.224
HWADDR=00:15:17:0B:01:4D

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=10.40.167.255
IPADDR=10.40.167.17
NETMASK=255.255.252.0
NETWORK=10.40.164.0
ONBOOT=yes
TYPE=Ethernet

/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=ncc9
GATEWAY=10.40.164.1

5 REPLIES 5
Steven E. Protter
Exalted Contributor
Solution

Re: linux dual nic interfaces configuration

Shalom,

No matter how many NIC cards you have you can only have one default route.

That will be the systems first choice concerning routing traffic.

After that it will use the gateway assigned to that NIC.

I do not see a compelling reason to change configuration. If there is a problem, you need to state it more clearly.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: linux dual nic interfaces configuration

If you want to configure static routes per interface, you need to create a file called:

/etc/sysconfig/network-scripts/route-ethX

For example:

Assume your eth0 device has the address 192.168.0.1 on the 192.168.0 network. You want to set a static route through the router
192.168.0.35 to reach the 10.0.35.0 network (netmask 255.255.255.0).
Using the 'ip route' syntax, the entry in route-eth0 might read

10.0.35.0/24 via 192.168.0.35

or

ADDRESS0=10.0.35.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.0.35
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
jerry1
Super Advisor

Re: linux dual nic interfaces configuration

I tried creating a config file:

/etc/sysconfig/network-scripts/route-eth1

ADDRESS1=10.40.191.0
NETMASK1=255.255.255.224
GATEWAY1=10.40.191.65


------------
I am assuming that the 0 after ADDRESS is
used by some startup script for eth0 in
your example. So I change it to 1 for eth1.
I rebooted and nothing happened.

I can't explain it any better if I do not
know what it is that I need to explain.
Other than I have a test network 10.40.191
with netmask of 255.255.255.224.

Test interface is 10.40.191.51
Router one hop away is 10.40.191.33

I tried also manually:

route add -net 10.40.191.0 netmask 255.255.255.224 gw 10.40.191.33 metric
1 dev eth1
Matti_Kurkela
Honored Contributor

Re: linux dual nic interfaces configuration

> I am assuming that the 0 after ADDRESS is
used by some startup script for eth0 in
your example.

No, it's just the number of the route definition. The first extra route in any route-eth* file must be ADDRESS0/NETMASK0/GATEWAY0, if there is a second one it must be ADDRESS1/NETMASK1/GATEWAY1, etc.

The interface is already specified by the filename, so there is no need to repeat that.

The scripts that add the actual routes will first check whether ADDRESS0 is defined or not. If it is, that route is added and the number is incremented by one. This will be repeated until there are no more route definitions.

If you don't use number 0, the loop will exit immediately.
MK
jerry1
Super Advisor

Re: linux dual nic interfaces configuration

Okay, I was able to finally figure out how
to add, manually, the network route to the
other vlan network 10.40.191.64. I just don't
understand how to put this in a file for
bootup.

route add -net 10.40.191.64 netmask 255.255.255.224 gw 10.40.191.33 dev eth1


I looked at /etc/init.d/network system
startup file and found these lines below,
but it does not make sense unless I put it
in as:

any "net 10.40.191.64 netmask 255.255.255.224 gw 10.40.191.33 dev eth1"



File /etc/init.d/network
.
.
# Add non interface-specific static-routes.
if [ -f /etc/sysconfig/static-routes ]; then
grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
/sbin/route add -$args
done
fi
.
.
.

It's Linux 2.6.12-2.3.legacy_FC3.