On Sun, 4 Jun 2006 14:28:21 -0400 Carl Hartung <suselinux@cehartung.com> wrote:
On Sunday 04 June 2006 14:00, it clown wrote:
Is there a way to force your network cards to stay eht0 and eth1 with the correct ip addresses?
Hi it clown,
Found this thread in my 'tips' archive:
I have SuSE linux 9.3 with two NIC's in it. Which was picked as eth0 and which as eth1 changed sometimes and I needed
Jason wrote: them to stay the
same. This was solved by setting their names to lan0 and lan1 using the PERSISTENT_NAME option in their configuration files. However, both NICs are on the same subnet and I need to be able to pick which one is used to communicate with other hosts on the same subnet. The routing table looks like this:
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.18.88.0 0.0.0.0 255.255.252.0 U 0 0 0 lan0 172.18.88.0 0.0.0.0 255.255.252.0 U 0 0 0 lan1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 172.18.91.254 0.0.0.0 UG 0 0 0 lan0
With this routing setup, communication with other hosts on the same subnet sometimes goes through lan0 and sometimes through lan1. I need to make sure it always goes through lan0. I was able to solve this manually by changing the metric for the route through lan1 as:
# route add -net 172.18.88.0 netmask 255.255.252.0 metric 5 dev lan1 # route del -net 172.18.88.0 netmask 255.255.252.0 metric 0 dev lan1 # route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.18.88.0 0.0.0.0 255.255.252.0 U 0 0 0 lan0 172.18.88.0 0.0.0.0 255.255.252.0 U 5 0 0 lan1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 172.18.91.254 0.0.0.0 UG 0 0 0 lan0
I would like to be able to make this happen automatically though. If I add an entry in the routes file for lan1 with a higher metric, I get multiple routes out lan1, one with a 0 metric and one higher.
# cat /etc/sysconfig/network/routes default 172.18.91.254 - lan0 172.18.88.0 - 255.255.252.0 lan1 - metric 5
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.18.88.0 0.0.0.0 255.255.252.0 U 0 0 0 lan0 172.18.88.0 0.0.0.0 255.255.252.0 U 0 0 0 lan1 172.18.88.0 0.0.0.0 255.255.252.0 U 5 0 0 lan1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 172.18.91.254 0.0.0.0 UG 0 0 0 lan0
I tried putting the metric 5 route in ifroute-lan1 instead of routes but that had no effect. How do I automatically delete or replace the 0 metric route out lan1? Is there a better way to do this than what I've tried so far?
Thanks,
Jason
Turns out there were a lot of ways to do this. The
file
/etc/sysconfig/network/ifcfg.template shows a few variables you can use and tells you to look at the man page of ifup and the files /etc/sysconfig/network/config,dhcp,wireless for more. I somehow overlooked what I need in the man page and didn't find it in the files but read the actual /sbin/ifup script and found the variable POST_UP_SCRIPT. I set it to POST_UP_SCRIPT='scripts/postup-lan1' in the config file for lan1, /etc/sysconfig/network/ifcfg-eth-id-mymacaddress where the contents of postup-lan1 are:
# cat scripts/postup-lan1 ifconfig | grep '^lan1' && route del -net 139.78.88.0 netmask 255.255.252.0 metric 0 dev lan1 ifconfig | grep '^lan1' && route add -net 139.78.88.0 netmask 255.255.252.0 metric 5 dev lan1
All is working as desired now.
Jason
hth & regards,
Carl
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Hi, Thanks for that got it working. Thanks Regards ___________________________________________________________________ For super low premiums, click here http://www.webmail.co.za/dd.pwm http://www.webmail.co.za the South African FREE email service -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com