guy labs guy labs

Configure a static IP in Ubuntu 13.04

 

 

Today we want to configure Ubuntu to use a static IP address instead of a dynamic one (from a DHCP server).

1. To do this we first need to switch from the default dhcp mode to the static mode. Open up the /etc/network/interfaces file and remove everything and add the following:

Ok lets go through the properties we set here:

  • The first two lines configure the loopback interface. These are default and shouldn’t be touched, unless you have a specific purpose.
  • The next two lines configure the eth0, the default wire connected interface. As you see it configures this it as static interface.
  • The properties we set till the dns properties should be self-explanatory.
  • The last the properties are about the DNS server. If you have a locally installed one you can configure it here with the dns-search and the dns-domain property. If you don’t have one you can use the ones from Google, namely 8.8.8.8,8.8.4.4

Save the file and exit the editor.

2. Ok now we need to delete the old config which generates the resolv.conf file and we need to remove the DHCP client. Please execute the following commands:

3. Ok no it’s time to restart the network interface with the following command:

This command executes the two packed command in order, such that we don’t get disconnected while executing a ifdown and then we can’t start it with the ifup. (In case you are connected via SSH) You can check the result by opening the nohup.out file in the folder where you ran the previous command.

4. Now we can test if everything is working. You first need to check that the DNS server you configured before are inside the /etc/resolv.conf file and that the output of ifconfig returns the correct configuration of the IP etc.
Next we can do a ping of google.com and a DNS lookup with the following commands:

The output of the ping should be something like this:

The output of the nslookup should be something like this:

Ok and that’s it for configuring a static IP in Ubuntu 13.04.

Thanks for reading the post and stay tuned!

Cheers

Guy

27,583 total views, 2 views today

Share Post :

2 Comments

  • Freeman
    October 7, 2013 6:49 PM at 6:49 PM http://a%20rel='nofollow'%20class='comment-reply-link'%20href='/2013/07/25/configure-a-static-ip-in-ubuntu-13-04/?replytocom=96#respond'%20data-commentid=96%20data-postid=232%20data-belowelement=comment-96%20data-respondelement=respond%20aria-label='Reply%20to%20Freeman'%20-%20Reply/a

    Thank you! This was very useful!

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.