Configure ethernet to get IP address from DHCP in Ubuntu and Debian

In this tutorial we will learn about how to configure ethernet to get IP address from DHCP Server in Ubuntu and Debian. Configuring the ethernet for getting ip address from DHCP server hardly takes 3-4 Steps.
The tutorial is applicable if you add new ethernet also. Here in this tutorial we have added one more Ethernet or Network Card in the system.

Follow the steps to configure the Ethernet in Ubuntu and Debian

Step 1: After login into the system.First check which Ethernet has not been assigned ip address either manually or via DHCP server.

sudo /sbin/ifconfig

As per the given below screenshot eth1 does not have any ip address,here we are configuring the eth1 to get IP Address from DHCP server

ubuntu network

Step 2: Now edit the /etc/network/interfaces file and add the below given lines for ethernet you want to configure.Below given is a syntax.And next is reference for eth1

Note: Replace ethernet-name with available ethernet in your system. For eg. eth0 ,eth1 etc

auto ethernet-name
iface ethernet-name inet dhcp

sudo vi /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp

Step 3: Now up the ethernet which was already down or you can restart the networking service also

Syntax:
ifdown ethernet-name (To down the ethernet)
ifup ethernet-name (To up the ethernet)

Example

sudo ifdown eth1
sudo ifup eth1

Alternatively, you can restart the networking service also

sudo service networking restart

OR 

sudo /etc/init.d/networking restart

Step 4: Now check the ip address with ifconfig command

sudo /sbin/ifconfig

or 

ifconfig

Leave a Comment

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