Note: This article was originally published in 2013. Some steps, commands, or software versions may have changed. Check the current Ubuntu documentation for the latest information.

In this step-by-step guide, you’ll learn enable dhcp and networking on ubuntu server. Ubuntu is a popular Linux distribution based on Debian, widely used for servers and development environments.

Prerequisites

Before you begin, make sure you have:

  • A system running Ubuntu (desktop or server edition)
  • Terminal access with sudo privileges
  • Basic familiarity with Linux command line

How to: Enable DHCP and Networking on Ubuntu Server

By default this is not an issues as you can configure networking from the setup wizard when you initially deploy your server. I unfortunately had some issues with networking with my VM so when I finally solved them I realized the Ubuntu Server had no network connectivity. I am not a huge fan of non-gui OSes for that reason, you need to type commands you don’t know to get things working. This goes for Windows Server Core as well… I do love what you can do with PowerShell but for mundane tasks I am happy with my GUI. I digress… in the case of Ubuntu you need to identify your network card and in the networking configuration allow it to automatically obtain an address from the DHCP server (alternatively you could set up a static IP address).

To quickly identify all available Ethernet interfaces, you can use the ifconfig command as shown below. ifconfig -a | grep eth

To configure your server to use DHCP for dynamic address assignment, add the dhcp method to the inet address family statement for the appropriate interface in the file /etc/network/interfaces. The example below assumes you are configuring your first Ethernet interface identified as eth0.

auto eth0
iface eth0 inet dhcp

By adding an interface configuration as shown above, you can manually enable the interface through the ifup command which initiates the DHCP process via dhclient.

**sudo ifup eth0**

To manually disable the interface, you can use the ifdown command, which in turn will initiate the DHCP release process and shut down the interface. sudo ifdown eth0

Static IP Address Assignment

To configure your system to use a static IP address assignment, add the static method to the inet address family statement for the appropriate interface in the file /etc/network/interfaces. The example below assumes you are configuring your first Ethernet interface identified as eth0. Change the address, netmask, and gateway values to meet the requirements of your network.

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

By adding an interface configuration as shown above, you can manually enable the interface through the ifup command. sudo ifup eth0 To manually disable the interface, you can use the ifdown command. sudo ifdown eth0 I obtained this from the Ubuntu website where you can find more information on how to configure things like routing, etc: https://help.ubuntu.com/10.04/serverguide/network-configuration.html

(http://img.zemanta.com/zemified_e.png?x-id=c10a00b0-fbe6-4d28-85ef-424d5350eb76)](http://www.zemanta.com/?px “Enhanced by Zemanta”)

Summary

You’ve successfully learned enable dhcp and networking on ubuntu server. If you run into any issues, double-check the prerequisites and ensure your Ubuntu environment is properly configured.