By default most Linux distributions including Ubuntu are configured with DHCP. This means that an IP address and some other parameters are configured automatically. The only issue with dynamic IP is that it can change making remote access a game of chance. Setting up static IP allows a user defined IP addresses that will remain the same unless changed manually.
You will need to gather some information prior to editing the configuration file. Specifically you will need to find your
Find the required network information.
Network interface is the physical device that connects to the network. This used to be generally
wlan0 for the first ethernet port and wireless adapter. With the new naming convention you may see different names. In my case there is only a single ethernet port named
Netmask is displayed as
Mask. In my case it was
Gateway is the IP of the router that connects to the internet. This is the same IP address you use to log in to your router configuration page. I had my router configured to use
192.168.0.1. If you don’t know your gateway you can easily find out from command line.
Look for the IP address under
Gateway column in a row with the value of
UG under the
DNS you can use Google Public DNS primary and secondary addresses which are
22.214.171.124 respectively. Alternatively you can have your router provide the
DNS service by supplying a gateway address.
Configure Static IP
Edit the network configuration file.
By default interfaces file should have configuration required for DHCP. We don’t want DHCP so we comment out the last two lines. You may need to revert back to DHCP so do not delete them. The first two lines are required for static and dynamic configurations alike.
# The loopback network interface auto lo iface lo inet loopback # The primary network interface #auto p3p1 #iface p3p1 inet dhcp
At the end of the file add the static IP configuration settings. Change the
netmask with previously noted details. Change address with the IP address of your choice making sure to stay away from low and high numbers to avoid clashes with DHCP addresses.
auto p3p1 iface p3p1 inet static address 192.168.0.100 gateway 192.168.0.1 netmask 255.255.255.0 dns-nameservers 126.96.36.199 188.8.131.52
Restart network services for the changes to take effect.
service network-manager restart
Verify the new static IP has been applied.
ifconfig route -n nano /etc/network/interfaces service network-manager restart ifconfig