coverup Posted March 29, 2005 Report Share Posted March 29, 2005 (edited) Edited: Okay, I contacted the developer, and he pointed that there is another tool, ifmetric, which allows one to assign priorities to interface devices. Apparently, it ships with mandrake 10.x (I've seen an RPM on www.pbone.net). Is there anybody out there who uses it, or have seen it being used in network interface configuration scripts? ======================= I need help with configuring ifplugd for monitoring two network interfaces. I would like to monitor and configure the wired eth0 and the wireless eth1 as follows: If the network cable connected, activate eth0 and use it as default gateway. If the cable is disconnected, switch to eth1 and use it as default gateway. So far, I did this # ifup eth0 # ifup eth1 # ifplugd --iface=eth0 The last command tells ifplugd to monitor eth0. Both interfaces are on the same network and connect to the same router. The default gateway is on eth0, and I can access the internet via eth0 just fine when the network cable is connected. When I pull out the cable, ifplugd shuts eth0 down. Ifplugd also removes the default gateway eth0 from the routing table, but it does not add a gateway entry for eth1 to the routing table. This prevents packets from going out through eth1. I thought running ifplugd --iface=eth1 would fix the problem, but to no avail. Nothing works, except manually configuring eth1 as the default gateway. Is there a way to make ifplugd not only tutn on/off interfaces but also configure default gateways? Help is appreciated. Edited March 31, 2005 by coverup Quote Link to comment Share on other sites More sharing options...
coverup Posted March 31, 2005 Author Report Share Posted March 31, 2005 I've edited the question a bit, does anybody know the answer? Quote Link to comment Share on other sites More sharing options...
coverup Posted April 2, 2005 Author Report Share Posted April 2, 2005 Ok, it appears that Mandrake 10.1 does use ifmetric. Which means you can have a "Windows type" connection, i.e., both the wired and wireless interfaces are up, and the system sends packets to the fastest interface connected? If somebody has this type of connection working, could you you then please post here the content of your ifcfg-eth0 and ifcfg-<wireless> as well as the output of ifconfig and route -n (run those as root). Much appreciate Quote Link to comment Share on other sites More sharing options...
arthur Posted April 2, 2005 Report Share Posted April 2, 2005 (edited) there should be a script called /etc/ifplugd/ifplugd.action that is executed whenever the state of the interface changes. if you run ifplugd with the options -r or --run=(script) then it will execute that script when the link status changes, and the default script is /etc/ifplugd/ifplugd.action. i'm not sure how the script should go, but it should be something simple like: /etc/init.d/net.eth0 stop /etc/init.d/net.eth1 start exit 0 but i'm running gentoo, so I'm not so sure how it would go on mandrake. also, won't linux applications automatically use the first available non-loopback interface, so you won't have to manually configure gateways? Edited April 2, 2005 by arthur Quote Link to comment Share on other sites More sharing options...
coverup Posted April 3, 2005 Author Report Share Posted April 3, 2005 Thanks, arthur. I had tried modifying ifplugd.action before, and did not succeed... Maybe, I gave up too easily. As for non-loopback interface, I would like to get a bit more control over which interface packets are being sent to. Quote Link to comment Share on other sites More sharing options...
arthur Posted April 3, 2005 Report Share Posted April 3, 2005 modifying ifplugd.action is not enough, you have to run ifplugd with the -r or --run=path option. like so $ifplugd --iface=eth0 --run=/etc/ifplugd/ifplugd.action about choosing to send packets to the fastest interface, that might be another matter, as you have to have a system of measuring the faster connection first (maybe pinging at regular intervals) but I'm not sure if ifplugd measures these. most command-line linux network programs can choose the network interface manually, like the nmap -e option: $ nmap -e eth1 hope this helps Quote Link to comment Share on other sites More sharing options...
coverup Posted April 3, 2005 Author Report Share Posted April 3, 2005 modifying ifplugd.action is not enough, you have to run ifplugd with the -r or --run=path option. like so $ifplugd --iface=eth0 --run=/etc/ifplugd/ifplugd.action <{POST_SNAPBACK}> Yep, got that working... I wrote two scripts, one brings down eth0 and brings up eth1 (wifi), another one does just an opposite thing. Then added those two scripts to ifplugd.action, ran the command as above, and it worked... Now, it remains to figure out how to start ifplugd on boot. Of course, it can be permanently added to /etc/rc.local, that however would be too easy.... I like to start ifplugd as service. That way, I can control whether to start this service for a particular netprofile. about choosing to send packets to the fastest interface, that might be another matter, as you have to have a system of measuring the faster connection first (maybe pinging at regular intervals) but I'm not sure if ifplugd measures these. This is done by modifying the interface metric in the routing table. If you have both eth0 and eth1 present in the routing table, run # ifmetric eth0 1 ifmetric eth1 0 and packets will go to eth1. To send packets to eth0, run # ifmetric eth0 0 ifmetric eth1 1 Unfortunately, I can't use this trick. The problem is that even when I start two interfaces, the scrips leave me with only one default gateway configured, the 2nd gateway has to be added manually (this could have been fixed in 10.1, as 10.1 scripts are a lot different). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.