By default your device IP is assigned by your router DHCP server and can change from one start to another. This might not be an issue but sometimes you may want to always have the same IP assigned to your device. For instance, when we installed Home Assistant on our Orange Pi Zero, we would prefer to always have the same IP to access Home Assistant.
Here I’ll show you how to setup a static IP in an ethernet connection in Armbian tested on an Orange Pi Zero (Armbian 5.59 stable Debian (stretch) 4.14.65).
Connect to your device via SSH.
Back up the /etc/network/interfaces file and edit it afterwards.
cp /etc/network/interfaces /etc/network/interfaces.backup sudo nano /etc/network/interfaces
And copy this Ethernet configuration, where the ‘address’ field contains the static IP address you want to assign to the device.
# Ethernet adapter 0 auto eth0 allow-hotplug eth0 #no-auto-down eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 192.168.1.1 #dns-nameservers 220.127.116.11 18.104.22.168
Exit by pressing Crtl+X and press Y to save the file.
If you have a previously configured Ethernet adapter as follows, remove that line from the interfaces file.
iface eth0 inet dhcp
Now you must reboot the system for the changes to take effect.
As we did the first time we connected to the device via SSH with the old IP address, when we connect to the new IP address we must accept the new key fingerprint to be added to our computer’s known_hosts file.
The authenticity of host '192.168.1.100 (192.168.1.100)' can't be established. ECDSA key fingerprint is SHA256:-------------------------------------------. Are you sure you want to continue connecting (yes/no)? yes