The problem: make sure I can connect to my raspberry pi B+ even if no network is available or network change.
The idea: set a static IP.
First some information:
- running raspbian 8.0 (cat /etc/issue)
- there is no need for a crossover UTP cable if you connect directly to the device you can use a normal cable
- IP configuration is delegated from /etc/network/interfaces to the dhcpcd daemon. This is why the eth0 is set on manual.
I did not wanted to crash default config. Just wanted to ensure the device will be visible. So I just added an aliased (virtual) interface with a fixed ip:
<pre lang="bash"># Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 10.13.0.201
netmask 255.255.255.0
network 10.13.0.0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
This is my /etc/network/interfaces. You can now use a normal UTP cable to connect directly to the PI or on the LAN by setting an IP in the same class:
<pre lang="bash">
ifconfig eth0 10.13.0.1 up
Please note that if you are on ubuntu and have a NetworkManager controlled interface you might need to disable auto-control by editing /etc/NetworkManager/NetworkManager.conf (see the unmanaged-devices section)
<pre lang="bash">
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
[ifupdown]
managed=false
[keyfile]
unmanaged-devices=mac:xx:xx:xx:xx:xx:xx