I have to connect my laptop to different wireless and wired networks in my daily work:
- DHCP wired nework at home.
- DHCP wireless network at home.
- Static IP wired usb network at work throw a Conceptronic cable (Prolific PL-2301/PL-2302 device - plusb module).
- Static IP wired ethernet network at work.
- Several sporadic wireless networks.
- To store several skills for different networks.
- To manage usb network connections.
So, I decide to use Network Manager to manage wireless connections while ifupdown take charge of the wired ones (usb and ethernet). Network Manager does not manage devices included into /etc/network/interfaces, so it is easy to use together these two applications.
I combine ifupdown application (ifupdown debian package) with resolvconf one (resolvconf debian pagackage) to allow dns entries inside interfaces file. This is my /etc/network/interfaces:
# Loopback
auto lo
iface lo inet loopback
# Ethernet networks
allow-hotplug eth0
iface eth0-home inet dhcp
iface eth0-work inet static
address w.x.y.z
netmask 255.255.255.0
network w.x.y.0
broadcast w.x.y.255
gateway w.x.y.1
dns-nameserver w.x.y.2
iface eth0-dhcp inet dhcp #default
mapping eth0
script /usr/local/sbin/ping-places.sh
map 192.168.1.254/24 192.168.1.1 eth0-home
map w.x.y.z/24 w.x.y.1 eth0-work
# usb network
allow-hotplug usb0
iface usb0 inet static
address 192.168.5.100
netmask 255.255.255.0
network 192.168.5.0
broadcast 192.168.5.255
gateway 192.168.5.1
dns-nameservers w'.x'.y'.z' w''.x''.y''.z''
dns-search domain.com
# wireless
allow-hotplug wlan0
where mapping stanzas and ping-places.sh script are used. I have copied ping-places.sh from /usr/share/doc/ifupdown/examples (ifupdown package) to /usr/local/sbin.
To configure one network, I have to plug the wire and power on the laptop. It will ping several routers to guess the network where it is wired. If, by error, you power on the laptop before connecting it, you can make:
# ifdown <interface>
# ifup <interface>
as root or sudoer, where <inteface> is eth0 or usb0.
For wireless networks you can work with Network Manager as usual.