This procedure will work many version of Ubuntu. I personally tested this on all Ubuntu versions from 12 and up, and should also work fine, or be a very good indicator of what to do, on any Debian based Linux distribution.
Like many OS out there, right after installation, everything is configured to use DHCP. Unless you have configured a static IP during the install process. This post will not cover this.
So first thing to do, once logged in you brand new OS, edit the network configuration file;
sudo nano /etc/network/interfaces
The file should look something like this:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp
Now, comment the “iface eth0 inet dhcp” line, and add all parameters to configure your interface manually. It should look like this:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 # iface eth0 inet dhcp iface eth0 inet static address 192.168.1.99 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 8.8.8.8 8.8.4.4
Change any parameter in there to suit your desired configuration.
You are done ! You can “reboot” for you settings to take effect, but that is a “Windows Admin” habit.
If you are in luck and using a common OS like Ubuntu 14+ You can do this for the IP to kick in without rebooting:
sudo ifdown eth0 && sudo ifup eth0
One Reply to “Configure static IP on Ubuntu”
For setting DNS, you can also do this:
Edit /etc/resolvconf/resolv.conf.d/base
Paste:
domain mydomain.com
search mydomain.com
nameserver 192.168.1.2
nameserver 192.168.1.3
Update resolvconf:
sudo resolvconf -u