Configure Ubuntu 13 Network Settings

Overview

Knowing how to configure your network interface in Ubuntu may come in handy when connecting to certain networks, or when you want to assign a specific IP address to your desktop, laptop or server. This tutorial will guide you through it using both the Unity desktop interface and the command line.

I will cover assigning both DHCP and Static IP from within the desktop and the command line. Remember, you will need administrative rights to make the change. If you do not already have sudo rights, which the first account created during installation does by default, you will have to request it from the adminstrator.

Static IP Addresses

From Command Line

  1. Open the network interfaces configuration file into a text editor, like VI or Nano.
    sudo vi /etc/network/interfaces
  2. Find the line for the first network interface, ETH0.
    auto eth0
  3. Modify the lines directly below it with the following, replacing the highlights values with those of your environment.
    auto eth0
    iface eth0 inet static
    address 172.16.10.200
    gateway 172.16.10.1
    netmask 255.255.255.0
    
  4. Save your changes and exit the text editor.
  5. Restart the network services to apply the changes.
    sudo /etc/init.d/networking restart
  6. To configure DNS, open the resolv.conf file into a text editor.
    sudo vi /etc/resolv.conf
  7. Add DNS search suffexes to enable resolving single-label names into fully qualified names, if they exist. Separate multiple domain names using a space ” “.
    search serverlab.ca dev.serverlab.ca
  8. To add DNS name servers, add the following, remembering to replace the highlighted values with those of your environment.
    nameserver 8.8.8.8
    nameserver 8.8.4.4
  9. Save your changes and exit the text editor.
  10. Changes will apply automatically. You do not need to restart any services.

 

From the Desktop

  1. Launch the Network Connections control panel by clicking the network icon (updown arrow icon) in the Application Indicator, and then click Edit Connections…

    Ubuntu Network Connections menu
    Ubuntu Network Connections menu
  2. In the Network Connections application, select the interface you want to configure, and then click Edit…

    Ubuntu network connections dialog box
    Ubuntu network connections dialog box
  3. In the Editing network interface name window that pops up, select the IPv4 Settings tab.

    Network connections dialog box - IPv4 Settings tab
    Network connections dialog box – IPv4 Settings tab
  4. Click the Method drop-down box and select Manual.
  5. Next to the Addresses table, click Add.
  6. Under the Address field, enter your static IP address.
  7. Under the Netmask field, enter the subnet mask for the network.
  8. Under the Gateway field, enter the IP address of your router.
  9. To set the DNS server IP addresses, enter them into the DNS Servers input box, using a comma to separate multiple servers.
  10. To set a DNS search domain, enter them into the Search Domains input box, using commas to separate multiple domains.

    Editing Ubuntu Network Connection dialog box
    Editing Ubuntu Network Connection dialog box
  11. Click Save… to save changes.
  12. Your new network settings should now apply. If not, you can apply them by click the network icon (up/down arrow) in the Application Indicator bar, and then click the network connections name.
    31-figure-05

Dynamic IP Addresses (DHCP)

From Command Line

  1. Open the network interfaces configuration file into a text editor, like VI or Nano.
    sudo vi /etc/network/interfaces
  2. Find the line for the first network interface, ETH0.
    auto eth0
  3. Modify the lines directly below it with the following, replacing the highlights values with those of your environment.
    auto eth0
    iface eth0 inet dhcp
  4. If there are lines similar to the following right below, remove them.
    address 172.16.10.200
    gateway 172.16.10.1
    netmask 255.255.255.0
  5. Save your changes and exit the text editor.
  6. Restart the network services to apply the changes.
    sudo /etc/init.d/networking restart

 

From the Desktop

  1. Launch the Network Connections control panel by clicking the network icon (updown arrow icon) in the Application Indicator, and then click Edit Connections…
    31-figure-01
  2. In the Network Connections application, select the interface you want to configure, and then click Edit…
    31-figure-02
  3. In the Editing network interface name window that pops up, select the IPv4 Settings tab.
    31-figure-03
  4. By default, the system should already be set to DHCP. If it is not, click the Method drop-down box and select Automatic (DHCP).
  5. Most DHCP services will automatically assign a DNS and search domain. However, you can override these settings by setting own.
  6. To override DNS settings, enter the IP address of your DNS host(s) in the Additional DNS Serversinput box.
  7. To add a search domain, for resolving single names into fully qualified names, enter the fully qualified name of the domain(s) you would like the system to search in the Additional Search Domains input box.
  8. Click Save to save your changes.

 

Setting the Hostname

You may not like the default hostname given to your computer, or you may need to change the name for other reasons. Use the following steps to update your computer’s name.

From Commandline

  1. Run the hostname command with your desired computer name.
    sudo /bin/hostname mycomputer

Network Bonding

Network bonding is a great tool that allows administrators to do things such as load balance an IP address over multiple network interface cards or create large aggregates to increase an interfaces bandwidth.

I’ve already covered bonding in Ubuntu 13 in two other tutorials.

Choose the appropriate tutorial to learn how it’s done.