From DHCP to static IP on ubuntu server

When you got a server it’s actually kinda nice to know the address always stays the same 🙂 It’s actually not that hard to configure… when you know what to change of course, so here goes… I’m using vim as a text editor, but you should use the one you feel most comfortable with. Lets open the network interface configuration file.

sudo vim /etc/network/interfaces

Normally you got eth0 (I got enp3s0 on mine though) as your primary network interface and you should see something like this:

auto eth0
iface eth0 inet dhcp

Lets remove those lines and replace them with the following: (you should of course use your own values)

auto eth0
iface eth0 inet static

Now we need to change the DNS settings in the resolv.config file.

sudo vim /etc/resolv.conf

add the line


Now you only have to restart the networking components:

sudo /etc/init.d/networking restart

There you go, just ping and you should get a response if you put in the correct information. Cheers /jima

Leave a Reply

Your email address will not be published. Required fields are marked *