automatic configuration of network interfaces (ifplugd?)
Hi, I have a thinkpad T42p notebook on which I run Suse 9.1. It has two network interfaces - eth0 (802.11 wireless) and eth1 (wired ethernet). I roam around a lot with this notebook and I would like a way to auto-configure my network interfaces. Currently, I always have to manually do ifdown eth0 ifdown eth1 ifup eth0 to enable wireless. Or, do ifdown eth0 ifdown eth1 ifup eth1 to enable wired ethernet. I read somewhere than ifplugd can be used to do something like this. What is your suggestion about how to do this? thanks, Osho
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 07 October 2004 11:49 am, Osho GG wrote: ...
to enable wired ethernet. I read somewhere than ifplugd can be used to do something like this.
Yes, ifplugd can do this. Here's how to set it up: - - Edit the configuration files for both interfaces under /etc/sysconfig/network/ifcfg-* and set STARTMODE=manual - - Edit /etc/ifplugd/ifplugd.conf and put both interfaces in INTERFACES - - Start ifplugd You may have a couple of problems: - - ifplugd cannot detect when my wireless interface goes up. I haven't had the time to figure it out. You might not have this problem - - dhcpcd will not set a default route if another dhcpcd is already running. I dealt with this by modifying /etc/ifplugd/ifplugd.action to look like this:: - ------ cut here ------ set -e if [ -z "$1" ] || [ -z "$2" ] ; then echo "Wrong arguments" > /dev/stderr exit 1 fi FAST_INTERFACE="eth0" SLOW_INTERFACE="wlan0" if [ "$2" = "up" ] ; then /sbin/ifup $1 # If this is the fast interface, we want to make sure the default route # is going through it if [ "$1" = "$FAST_INTERFACE" ] ; then if [ -r /var/lib/dhcpcd/dhcpcd-$FAST_INTERFACE.info ] ; then . /var/lib/dhcpcd/dhcpcd-$FAST_INTERFACE.info /sbin/ip route del default 2> /dev/null || true /sbin/ip route add default via $GATEWAY dev $FAST_INTERFACE fi fi fi if [ "$2" = "down" ] ; then /sbin/ifdown $1 # If this is the fast interface, we want to switch the default route to # the slow interface, if it's active if [ "$1" = "$FAST_INTERFACE" ] ; then # Is the slow interface active? /sbin/ip route | grep -q "$SLOW_INTERFACE" if [ "$?" = 0 ] ; then if [ -r /var/lib/dhcpcd/dhcpcd-$SLOW_INTERFACE.info ] ; then . /var/lib/dhcpcd/dhcpcd-$SLOW_INTERFACE.info /sbin/ip route del default 2> /dev/null || true /sbin/ip route add default via $GATEWAY dev $SLOW_INTERFACE fi fi fi fi exit 0 - ------ cut here ------ Hope that helps, - -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBZXm04U2uQswGyDcRAs9DAJ9s+NX/j16X5dL7kDlTkLoY13cgSwCdEQdl yaF1vAb8v6JPjQ4TTG7AAoc= =kTS1 -----END PGP SIGNATURE-----
Thanks much for the detailed instructions. This worked for me.
Whenever either of the interface is up, I see that ifplugd gets a
notification (I see the messages in /var/log/messages). It worked
consistently or wired and wireless both - so far.
The only issue I have is that when an interface goes down, the script
doesn't reach after
/sbin/ip route | grep -q "$SLOW_INTERFACE"
I put echo statement before and after this statement like
echo before
/sbin/ip route | grep -q "$SLOW_INTERFACE"
echo after
Only the before is seen in /var/log/messages, after is not. I also see
a message saying the script exited with exit status 1 or 2.
If I execute the same /sbin/ip route | grep -q eth0 or /sbin/ip route
| grep -q eth1 command on the command line - I never see that it exits
with some other status. So, I removed that check and the script now
kinda works.
Any idea what could be wrong?
thanks,
Rajnish
On Thu, 7 Oct 2004 14:15:18 -0300, James Oakley
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thursday 07 October 2004 11:49 am, Osho GG wrote: ...
to enable wired ethernet. I read somewhere than ifplugd can be used to do something like this.
Yes, ifplugd can do this. Here's how to set it up:
- - Edit the configuration files for both interfaces under /etc/sysconfig/network/ifcfg-* and set STARTMODE=manual
- - Edit /etc/ifplugd/ifplugd.conf and put both interfaces in INTERFACES
- - Start ifplugd
You may have a couple of problems:
- - ifplugd cannot detect when my wireless interface goes up. I haven't had the time to figure it out. You might not have this problem
- - dhcpcd will not set a default route if another dhcpcd is already running. I dealt with this by modifying /etc/ifplugd/ifplugd.action to look like this::
- ------ cut here ------ set -e
if [ -z "$1" ] || [ -z "$2" ] ; then echo "Wrong arguments" > /dev/stderr exit 1 fi
FAST_INTERFACE="eth0" SLOW_INTERFACE="wlan0"
if [ "$2" = "up" ] ; then /sbin/ifup $1
# If this is the fast interface, we want to make sure the default route # is going through it if [ "$1" = "$FAST_INTERFACE" ] ; then if [ -r /var/lib/dhcpcd/dhcpcd-$FAST_INTERFACE.info ] ; then . /var/lib/dhcpcd/dhcpcd-$FAST_INTERFACE.info /sbin/ip route del default 2> /dev/null || true /sbin/ip route add default via $GATEWAY dev $FAST_INTERFACE fi fi fi
if [ "$2" = "down" ] ; then /sbin/ifdown $1
# If this is the fast interface, we want to switch the default route to # the slow interface, if it's active if [ "$1" = "$FAST_INTERFACE" ] ; then # Is the slow interface active? /sbin/ip route | grep -q "$SLOW_INTERFACE" if [ "$?" = 0 ] ; then if [ -r /var/lib/dhcpcd/dhcpcd-$SLOW_INTERFACE.info ] ; then . /var/lib/dhcpcd/dhcpcd-$SLOW_INTERFACE.info /sbin/ip route del default 2> /dev/null || true /sbin/ip route add default via $GATEWAY dev $SLOW_INTERFACE fi fi fi fi
exit 0 - ------ cut here ------
Hope that helps,
- -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBZXm04U2uQswGyDcRAs9DAJ9s+NX/j16X5dL7kDlTkLoY13cgSwCdEQdl yaF1vAb8v6JPjQ4TTG7AAoc= =kTS1 -----END PGP SIGNATURE-----
-- 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
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 08 October 2004 2:16 am, Osho GG wrote:
Thanks much for the detailed instructions. This worked for me. Whenever either of the interface is up, I see that ifplugd gets a notification (I see the messages in /var/log/messages). It worked consistently or wired and wireless both - so far.
The only issue I have is that when an interface goes down, the script doesn't reach after
/sbin/ip route | grep -q "$SLOW_INTERFACE"
I put echo statement before and after this statement like
echo before /sbin/ip route | grep -q "$SLOW_INTERFACE" echo after
Only the before is seen in /var/log/messages, after is not. I also see a message saying the script exited with exit status 1 or 2.
If I execute the same /sbin/ip route | grep -q eth0 or /sbin/ip route
| grep -q eth1 command on the command line - I never see that it exits
with some other status. So, I removed that check and the script now kinda works.
Any idea what could be wrong?
That's really strange. I don't have that problem. What does it say if you change: /sbin/ip route | grep -q "$SLOW_INTERFACE" to simply: /sbin/ip route - -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBZtwN4U2uQswGyDcRAjE7AJ9wV8sZXPOMaUWrpm6qZ4Y0SuRyxwCfRPU5 xG7ua5sUdPCodeLU04WzLmU= =JDuW -----END PGP SIGNATURE-----
Hi,
I tried changing to /sbin/ip route and then the script went past that.
I did some more debugging to figure out what was going on. What I
found was that if I put the following at the very top
echo BEFORE
false
echo AFTER
The script would never reach till AFTER. This was because of set -e
line. I removed the set -e line and then I will get both BEFORE and
AFTER. Reading sh man page seems to indicate that doing "set -e"
forces the script to exit immediately if any of it's "untested"
command exits with non-zero values. I removed set -e and now it is
working as expected.
thanks for your help,
Osho
On Fri, 8 Oct 2004 15:27:08 -0300, James Oakley
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Friday 08 October 2004 2:16 am, Osho GG wrote:
Thanks much for the detailed instructions. This worked for me. Whenever either of the interface is up, I see that ifplugd gets a notification (I see the messages in /var/log/messages). It worked consistently or wired and wireless both - so far.
The only issue I have is that when an interface goes down, the script doesn't reach after
/sbin/ip route | grep -q "$SLOW_INTERFACE"
I put echo statement before and after this statement like
echo before /sbin/ip route | grep -q "$SLOW_INTERFACE" echo after
Only the before is seen in /var/log/messages, after is not. I also see a message saying the script exited with exit status 1 or 2.
If I execute the same /sbin/ip route | grep -q eth0 or /sbin/ip route
| grep -q eth1 command on the command line - I never see that it exits
with some other status. So, I removed that check and the script now kinda works.
Any idea what could be wrong?
That's really strange. I don't have that problem.
What does it say if you change:
/sbin/ip route | grep -q "$SLOW_INTERFACE"
to simply:
/sbin/ip route
- -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBZtwN4U2uQswGyDcRAjE7AJ9wV8sZXPOMaUWrpm6qZ4Y0SuRyxwCfRPU5 xG7ua5sUdPCodeLU04WzLmU= =JDuW
-----END PGP SIGNATURE-----
-- 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
participants (2)
-
James Oakley
-
Osho GG