How to set dynamic IP address on Ubuntu 16.04?

To set dynamic IP address on Ubuntu 16.04, you can follow these steps:

  1. Open the terminal by pressing Ctrl+Alt+T.
  2. Type the command “sudo vi /etc/network/interfaces” and press Enter. This will open the “interfaces” file in the vi text editor with root privileges.
  3. Find the line for the network interface you want to configure (e.g., “iface eth0 inet dhcp”) and ensure that it is configured for “dhcp” for dynamic IP address. If not, change “static” to “dhcp”.
  4. Save and close the file by pressing Ctrl+O, Enter, and then Ctrl+X.
  5. Restart the networking service to apply the changes by typing the command “sudo service networking restart” and pressing Enter.
1
2
3
4
5
6
7
8
9
10
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The Ethernet network interface
auto eth0
iface eth0 inet dhcp

Your network interface should now be configured to obtain an IP address dynamically. You can confirm the change by using the “ip addr show” command and checking for an IP address assigned by DHCP server.ver.