You are not logged in.
I've read a bunch of threads on netcfg, and I'm not finding the answer that I'm looking for. As the title tries to say, I want netcfg to attempt to connect to ethernet first. If it's successful, then skip the wireless profile. If it's not successful, then try wireless. The profiles are fine, I just need to know the setup. What simple thing am I missing?
Offline
That's what I'd like to see with netcfg too - it can't handle priorities apart from its own (internal) priority setting afaik. Since your ethernet connection usually is the fastest in comparison to the wireless ones, shouldn't it skip the wireless ones automatically?
Offline
netcfg is a dumb network connector. It just connects to things. It doesnt enforce any policies.
It is however flexible and reusable, and it would be trivial to implement a tool that does what you'd like.
Last edited by iphitus (2009-03-01 09:10:06)
Offline
I would love to see this abiility in netcfg2, because I often switch between ethernet with static ip and wireless with dhcp. That's why I'm using wicd right at the moment, which is really good, but I still like netcfg2 better.
Offline
You should be able to realize this sort of functionality with properly configured ifplugd. You can use it do define actions that depend of the status of various network interfaces -- so basically you can set it to run netcfg to configure wifi interface when ethernet cable is not connected, and to disable wifi and configure ethernet connection when the ethernet cable is plugged in.
I don't use it with netcfg, I use a different script to connect to wifi networks, but it should work without problems.
Offline
Thanks for the responses. ifplugd looks pretty cool. I'll check it out. Thanks fwojciec.
I need to start learning more about networking. It's by far my greatest weakness in system configuration.
Offline
@skottish: Could you please show us, what you've done, as soon as you got this? I think I'll try it as well, but trust me, I'm a total dumb-ass in networking
Offline
Hi, I came across this need as well and I patched netcfg like this: http://pastebin.com/f1c83c27c
Just apply the patch and modify /etc/rc.conf like this:
NETWORKS=(wired)
AUTO_NETWORKS=(auto-wireless wlan0)
...
DAEMONS=(... @net-profiles ...)
where 'wired' is your wired profile and wlan0 is your wifi card's interface.
Happy hacking
Offline
I had totally forgotten about this thread.
I initially marked the thread as solved because of fwojciec's post. It seemed that scripting around ifplug was a simple and elegant solution.
But, my last remaining braincell started to function. The person that has this computer only uses it at her work to connect through ethernet. The only time the machine connects through wireless is when it's with me, and that's only for upgrades and repairs. So basically I used netcfg to try both interfaces. One works and one fails.
[SOLVED]=hacked!
Offline
I found it's hard to use ifplugd with netcfg2. And Venator85's solution seems more applicable.
However, I'm wondering how to hack the ifplugd.
Offline
I can post my solution, but as I said I don't use netcfg, so it can't be copied verbatim. Here is my custom version of ifplugd.action script (/etc/ifplugd/ifplugd.custom.action):
#!/bin/sh
#
# custom ifplugd.action script
#!/bin/sh
#
# custom ifplugd.action script
case "$2" in
up)
if [ -f /var/run/daemons/wpa_auto ]; then
/etc/rc.d/wpa_auto stop
ifconfig $1 up
dhcpcd $1
fi
;;
down)
if [ -f /var/run/dhcpcd-$1.pid ]; then
dhcpcd -qx $1
ifconfig $1 down
fi
if [ ! -f /var/run/daemons/wpa_auto ]; then
/etc/rc.d/wpa_auto start
else
/etc/rc.d/wpa_auto reset
fi
;;
*)
echo "Wrong arguments" > /dev/stderr
exit 1
;;
esac
exit 0
This is my ifplugd.conf:
NET_IFS="eth0"
ARGS="-fwI -u0 -d10 --run=/etc/ifplugd/ifplugd.custom.action"
I start the ifplugd daemon after the wifi networking script in rc.conf...
Now that I think about it, this might be an important difference between the script I use (wpa_auto) and netcfg -- wpa_auto doesn't fail if no wifi network is available, it simply waits in the background and monitors wifi environment until one of the networks defined in wpa_supplicant.conf becomes available to connect to it. So the configuration with netcfg would have to be a bit more creative...
Offline
@Venator85: Thanks for your solution. That's work perfectly here.
nice piece of hack.
Offline
This solution isn't working perfect anymore. The kernel change in rfkill ruined this solution for me.
When I boot up my laptop with the hardware rfkill switch to 'no radio' (I have to do this @ work) wpa_auto won't start. And when wpa_auto isn't running, case $2 won't bring up eth0 for me.
I'm going to look into this but if anyone else has the right changes for the ifplugd action script, feel free to beat me to fixing this
Offline
OK, I just added some checks.
In my case wpa_auto isn't running when I startup with the hardware switch set to 'no radio'. So I extracted the ifconfig and dhcpcd from that check:
case "$2" in
up)
# Bring down wpa_auto daemon, if running
if [ -f /var/run/daemons/wpa_auto ]; then
/etc/rc.d/wpa_auto stop
fi
# Bring up $1, if down
if [ "$IFPLUG_CURRENT" -ne "up" ]; then
ifconfig $1 up
fi
# Trigger dhcpcd $1, if not already running
if [ ! -f /var/run/dhcpcd-$1.pid ]; then
dhcpcd $1
fi
;;
Last edited by aapzak (2009-10-21 13:19:44)
Offline