Create two simple 'scripts', the name of the script is not important (I simply use wlan) and I assume there is only one cabled network interface, and is thus called 'eth0'... Check this with 'ifconfig' if you're not sure.
Note that this disabled wireless entirely, not just wlan0. (Only an issue if you have multiple wlan interfaces and only want to disable specific ones)
These scripts could easily be adapted - by boolean logic - to a situation in which you have two or more cabled network interfaces.
Make sure these scripts are executable with 'chmod +x'
/etc/network/ip-up.d/wlan
#!/bin/sh
# If eth0 goes up, disable wireless
if [ "$IFACE" = "eth0" ]; then
dbus-send --system --type=method_call --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.DBus.Properties.Set string:org.freedesktop.NetworkManager string:WirelessEnabled variant:boolean:false
fi
/etc/network/if-down.d/wlan
#!/bin/sh
# If eth0 goes down, enable wireless
if [ "$IFACE" = "eth0" ]; then
dbus-send --system --type=method_call --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.DBus.Properties.Set string:org.freedesktop.NetworkManager string:WirelessEnabled variant:boolean:true
fi
This enables/disables wireless in the NetworkManager that can usually be found as an system indicator in the Gnome panel.
You could also use 'ifconfig wlan0 down' or 'ifconfig wlan0 up' instead of the dbus-send line, but this should be more user-friendly and interfere less with Ubuntu's system utilities.
Tested with Ubuntu Desktop 10.10, and should work with earlier versions or other distributions using NetworkManager and dbus.
The answer for this question varies from computer to computer. I don't know if Ubuntu allows this, but typically I've found it's an option in the BIOS. – Iszi – 2011-01-14T23:27:00.353
I don't mean
completely disable
the wlan, i mean disable Ubuntu to try to connect to any wlans if a wired connection is available. So it is an OS thing. – Ingo Fischer – 2011-01-14T23:37:27.570