I have a situation where I have a headless computer running Ubuntu 12.04 that I primarily connect to via SSH. It is headless because it is inside a robot, and connecting a monitor and keyboard are very inconvenient. It is bare-bones Ubunu installation - no X server, no NetworkManager. It currently connects to a wifi router using a configuration specified in /etc/network/interfaces. Because I connect to it using SSH, the computer uses a static IP whenever it boots. The current wifi configuration works, but I want to add support for wired connections and direct local-link ethernet connections. (Because who wants to drag a WiFi router around everywhere, and also Ethernet is more reliable, and also can be faster.)
What I want to do, but don't know how to do, is write an /etc/network/interfaces file that generates the following behavior on boot:
Code:
(This is pseudocode)
IF link-local connection exists:
set up eth0 with static IP1
ELSE IF wired router connection exists:
set up eth0 with static IP2
ELSE IF no Ethernet plugged in:
set up wlan0 with static IP3
END
link-local is a direct computer-to-computer Ethernet connection. I don't know how to set that up. I also haven't been able to find an example demonstrating how to generate this kind of "fallback" behavior. I do not want to bridge any connections, I don't think. I think that using pre-up and post-up commands might be the key to achieving the fallback behavior, because they could run a script that check if the interface is already configured, but don't know exactly how. The robot just needs to do this network setup once on boot - it is very cheap to reboot the robot (only takes 5 seconds) so even if it is not robust to manual ifdown ifup commands that wouldn't matter. Here is my current /etc/network/interfaces file that I'm starting with:
Code:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
#auto eth0
#iface eth0 inet dhcp
auto wlan0
iface wlan0 inet static
address 192.168.0.23
netmask 255.255.255.0
gateway 192.168.0.1
broadcast 192.168.0.255
wpa-ssid metHubo
wpa-psk [removed]
dns-nameservers 192.168.0.1
If someone could post a dummy /etc/network/interfaces file showing how to do the fallback from link-local to wired router to wireless router, that would be great.
Bookmarks