Click to See Complete Forum and Search --> : Add second gayeway for new NIC


herbie
02-21-2006, 04:27 PM
I have a system with 4 NICs, and want to change eth3 to work on a different network.
route -n

Destination Gateway Genmask Flags Metric Ref Use Iface
204.244.xxx.192 0.0.0.0 255.255.255.192 U 0 0 0 eth3
172.16.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
172.16.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
207.194.xxx.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 207.194.110.254 0.0.0.0 UG 0 0 0 eth0

I want to add a different gateway to eth3

It would be nice if there was a command line method to do this to try out.
I tried adding it into ifcfg-eth3 but all I get are errors

ph34r
02-21-2006, 04:56 PM
check the man pages for ifconfig and route

herbie
02-21-2006, 05:34 PM
gee, thx :?

I did:
ifconfig eth3 204.244.94.254 netmask 255.255.255.192 up
then
route add 204.244.94.254/26 gw 204.244.94.193


Destination Gateway Genmask Flags Metric Ref Use Iface
204.244.94.254 204.244.94.193 255.255.255.255 UGH 0 0 0 eth3
204.244.94.192 0.0.0.0 255.255.255.192 U 0 0 0 eth3
172.16.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
172.16.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
207.194.110.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 207.194.110.254 0.0.0.0 UG 0 0 0 eth0

can't poing gateway at .193....

knute
02-21-2006, 11:00 PM
Check your netmasks.

herbie
02-21-2006, 11:58 PM
route add 204.244.94.254/26 gw 204.244.94.193
is not the same ad
route add 204.244.94.254 netmask 255.255.255.192 gw 204.244.94.193 ?
I couldn't get the second syntax to work, thought /26 subnet = .192...

herbie
02-23-2006, 01:01 AM
the ifcfg-eth3 adds the line
dest 204.244.94.192 gw 0.0.0.0 genmask 255.255.255.192 U if you route -n
but 0.0.0.0 gives you to the default gw
I guess I need to know how to correct this to add gw 204.244.94.193
route add 204.244.94.192 gw 204.244.94.193 dev eth3
adds
dest 204.244.94.192 gw 204.244.94.193 genmask 255.255.255.255 UGH
gateway still unreachable

herbie
02-23-2006, 11:31 PM
soved:
route add -net 204.244.94.192 netmask 255.255.255.192 gw 204.244.94.193 dev eth3

the screen resolution did not allow this to be entered on a single line
this can be added to the rc.local file

now I can work on how to make internal IP A route through eth0 and IP B route through eth3