Setting up a static IP address in Ubuntu

sudo gedit /etc/network/interfaces

Change the line iface eth0 inet dhcp to iface eth0 inet static and add the following just below it:

address 192.168.1.100 (IP address of what you want your Ubuntu machine to be)
netmask 255.255.255.0
(Default mask which in this case is the default class c subnet)
gateway 192.168.1.1  
(Typically your router’s IP address)
network 192.168.1.0 
(The network that this machine is running on)
broadcast 192.168.1.255
 (A message that is sent to all out network-attached hosts to essentially find a specific address. You also receive them from other hosts)
dns-nameservers 192.168.1.1
 (DNS or Domain Name Server used for responding to queries when you are searching for a website)

sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start
原文地址:https://www.cnblogs.com/zl0372/p/static_ip.html