It's work on all relases since 2016
Not edit /etc/network/interfaces !
Open /etc/dhcpcd.conf
sudo nano /etc/dhcpcd.conf
Scroll to bottom of this file and add your config as is explained in example.
- Interface values
eth0for lan(cable),wlan0for wirless(wifi) - In
ip_addressyou can write any ip you want. Make sure you add/24at the end - Both
routers(Gateway IP) anddomain_name_server(DNS ip) in normal situation refer to IP of your router
Example configuration:
interface eth0
static ip_address=192.168.1.5/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
interface wlan0
#(...)
When you are done, press Ctrl+o to save file and Ctrl+X to exit nano.
At the end reboot system and enjoy your new static IP. (After reboot you can check you ip using ifconfig)
On ssh double-check IP you set and reboot only if you absolutely sure.