Part 1 here. This post concerns setting up a Static IP for Ethernet and Wi-Fi and the problems with setting up the latter.
Setting a Local Static IP (Ethernet)
To set the static IP, I followed this guide here, everything from the start to the first reboot. The guide is pretty good, but it flummoxed me on the 'network' option in the static ip.
I put a total guess in as 192.168.1.0, based on the table produced from 'sudo route -nee', where 192.168.1.254 is the Gateway and 192.168.1.0 is the Destination. Total guess, but it worked.
Destination | Gateway | Genmask 0.0.0.0 | 192.168.1.254 | 0.0.0.0 192.168.1.0 | 0.0.0.0 | 255.255.255.0
Here's the static ip I pasted into the file:
iface eth0 inet static address 192.168.1.220 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254
Now that I have set a local Static IP, the ssh [email protected] no longer works. I have to use the IP to SSH in.
Static IP for my Network
Next step was enabling a Static IP for my router, so I can access my Pi from afar. I use Plusnet, so I enabled it on the AddOns page here for £5.
Next, I port-forwarded my Router to the IP of my Pi, on port 22 so I can ssh in. I picked a port at random on the router. I used this guide here as I have a Technicolor Gateway. This way anywhere around the world I can ssh ip -p randomport and it'll forward it to the right port.
At first this guide didn't work (and neither did the Wi-Fi GUI) until I changed iface wlan0 inet dhcp to 'manual' instead of 'dhcp'. That was 15 minutes I'll never get back.
For some reason at the top of my interfaces file it was set to 'auto lo' which I think sets it to localhost automatically. 'auto wlan0' fixed it. They mention this in the guide but I completely missed it.
Wi-Fi Static IP
Next step - setting it up so it has a static IP on the Wi-Fi. I put the same IP, netmask etc as the Ethernet on the Wi-Fi adapter by editing /etc/network/interfaces & /etc/wpa_supplicant/wpa_supplicant.conf.
In the guide they don't include a broadcast or network item. I kept exactly the same items as was on the ethernet. I also had to change 'manual' to 'static' as expected. After some wrangling, it has the IP address! Except it doesn't have an internet connection. Argh!
Rolling back my changes puts me back on dynamic IP address.
Next time... hard drives! More power! And maybe I'll fix the Wi-Fi.