How to change from DHCP to Static IP Address in Ubuntu 17.04

12/02/2020

Before we proceed with how to change from DHCP to Static IP Address in Ubuntu 17.04, lets review what a DHCP is and why you might want to switch to a static IP instead.

DHCP which stands for Dynamic Host Configuration Protocol, is a network service that allows computer hosts in a network to be assigned settings automatically from another server, instead of manually configuring each network host. Computers configured to be DHCP clients have no control over the settings it receives from the DHCP server, and the configuration is transparent to the computer’s user.

Why Switch to Static?

One and probably the most comon reason why adminsitrators switch from a DCHP assigned settings to a manually configured settings is if the the computer or server is runing a service that requires others to access via its IP address especially in an environment where DNS isn’t setup. This is typically found in an intranet setup meaning its only available local on the internal network.

How to change from DHCP to Static IP Address

  • There are 2 ways we can do this. Either using the GUI network manager interface or via the command line

Using Network Manager GUI

  • Click on the Ethernet Network icon at top right and click Edit Connections…

change from DHCP to Static IP Address

  • Select the network and click Edit

change from DHCP to Static IP Address

  • Click the IPv4 Settings tab > Change Method from DHCP to Manual

change from DHCP to Static IP Address

  • Click the Add button under Addresses and enter the details as seen below (Obvious the IP/Netmask/Gateway will be yours). If you have a DNS server, enter the IP as well

change from DHCP to Static IP Address

  • Save changes and restart your network daemon by running the following command
sudo /etc/init.d/network-manager restart

Change via the network interface using the command line

  • First we disable the network configuration daemon to avoid any interferance
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
  • Indentify your network adapter name by running following commands
ifconfig -a

As seen, mine is called enp0s3

change from DHCP to Static IP Address

  • Next lets change the configuration on /etc/network/interfaces from dhcp to static by running the following command in terminal. First lets install vim editor because of its unique looks
sudo apt-get install vim
sudo vim /etc/network/interfaces
  • Now replace the content in the file with following. Note: I have commented on lines that needs replacing or add incase your file contains more info
auto lo enp0s3 #here replace the adapter name with yours
iface lo inet loopback # leave this

# add the following lines
iface enp0s3 inet static
address 192.168.0.55
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 4.2.2.2

change from DHCP to Static IP Address

  • Save changes using cntrl + x and restart ubuntu network interface
sudo /etc/init.d/networking restart

or
sudo systemctl restart networking

Note: If after restarting the services, the changes does not take effect, then reboot the machine.

change from DHCP to Static IP Address

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to use the touch command on Ubuntu

“touch” is a basic Linux command to create empty files or change files timestamps (last date or time of file access...
29/12/2020

Ubuntu 18.04 LTS NEW FEATURES

With the first beta release of Ubuntu 18.04 LTS available and the stable released planned on 26 April 2018, now is a great...
28/12/2020

Check for and Patch Spectre and Meltdown on Ubuntu

How to Check for and Patch Spectre and Meltdown Vulnerability on Ubuntu 17.10 Artful Aardvark Before I show you how to check...
12/02/2020
Bài Viết

Bài Viết Mới Cập Nhật

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024