Set static IP Ubuntu 16.04

Changing Ubuntu Server from DHCP to Static IP Address (Ubuntu Server 16.04 TLS)

Recently, created a couple of LAMP stacks with Ubuntu 16.04 and needed to issue a Static IP so that it could be NAT’d as a web server.

I have used this command
Step 1.

sysadmin@ubuntu:~$ sudo nano /etc/network/interface

auto ens160
iface ens160 inet dhcp


Step 2. Change dhcp to static and edit the IP Address/Subnetmask/Gateway (in bold)

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

 # The primary network interface
auto ens160
iface ens160 inet static
address 192.168.1.48
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 4.4.4.4 (or Internal DNS Servers)

Step 3. Now restart the networking service

sysadmin@ubuntu:~$sudo service networking restart

This seems to do the trick for our Ubuntu Server 16.04 TLS. Try it out.

 

References

How-to-Geek (2016). Change Ubuntu Server from DHCP to a Static IP Address. Retrieved from: http://www.howtogeek.com/howto/ubuntu/change-ubuntu-server-from-dhcp-to-a-static-ip-address/

 

Ubuntu Official Help Documentation (2016). Network Configuration. Retrieved from: https://help.ubuntu.com/lts/serverguide/network-configuration.html

Follow Us On
Twitter
fb-art Postwaves

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s