How To Set Static IP Ubuntu 16.04

Step 1: Set static IP address

1.1 Edit config file

sudo nano /etc/network/interfaces

1.2 Comment out

#iface ens160 inet dhcp

NOTE: Network card name can change depending on your installation

1.3 Copy and add the lines below:

# Modify the parameters to match your network and network interface

#iface ens160 inet dhcp

iface ens160 inet static
                   address 192.168.100.16
                   network 192.168.100.16
                   netmask 255.255.255.0
                   broadcast 192.168.100.255
                   gateway 192.168.100.1
                   dns-nameservers 192.168.100.11, 8.8.4.4

Exit and Save

1.4 Restart init.d

sudo /etc/init.d/networking restart
root@srv6:/# sudo /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.
root@srv6:/#

1.5 Reboot the server

sudo reboot

Step 2: Verify Connectivity

2.1 Verify IP address

sudo ifconfig
steken@srv6:~$ sudo ifconfig
[sudo] password for steken:
ens160    Link encap:Ethernet  HWaddr 00:0c:29:ae:be:58
          inet addr:192.168.100.16  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feae:be58/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:350 errors:0 dropped:0 overruns:0 frame:0
          TX packets:272 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:376488 (376.4 KB)  TX bytes:26045 (26.0 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

steken@srv6:~$

2.2 Check default route

sudo route -n

2.3 Check internet connectivity

sudo ping 8.8.8.8

2.4 Check DNS

sudo ping www.google.com
steken@srv6:~$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.1   0.0.0.0         UG    0      0        0 ens160
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 ens160
steken@srv6:~$ sudo ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=7.76 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=7.84 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 7.764/7.805/7.846/0.041 ms
steken@srv6:~$ sudo ping www.google.com
PING www.google.com (172.217.20.36) 56(84) bytes of data.
64 bytes from arn11s01-in-f4.1e100.net (172.217.20.36): icmp_seq=1 ttl=52 time=8.11 ms
64 bytes from arn11s01-in-f4.1e100.net (172.217.20.36): icmp_seq=2 ttl=52 time=7.89 ms
^C
--- www.google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 7.899/8.008/8.117/0.109 ms
steken@srv6:~$

Donate