How to Change IP Address on Ubuntu

12/02/2020

In this post we will try to change the IP address of a Ubuntu based Linux system from the command line. Though we will be using Ubuntu 16.04 but the steps should work for any version of Ubuntu.

Listing Network Interfaces

We will start by listing all network interfaces for your system. We are doing this so that we know the name of the network for which we want to modify the IP address. Now, go on and run the following command:

ifconfig

Once we run this command, we will see something like:

So, we have two networks mentioned here with much more metadata. To change settings of a network, we will make use of the same command with few more parameters.

Additional parameters with ifconfig

Let’s write a command using ifconfig which will change the IP address of the network ‘enp0s3’ to 192.168.0.1 and also changes the subnet mask 255.255.255.0:

sudo ifconfig enp0s3 192.168.0.1 netmask 255.255.255.0

When we run this, we don’t get anything back:

This time, when we again run the ifconfig command, we will see that IP address have changed:

Changing the Default Gateway

We can also modify a network’s gateway with simple command as:

Of course, no output is returned. But we can check the settings with this command:

route -n

Let’s run this now:

That’s all. It was super easy to change your IP from the command line. Do check out other linux based lessons as well!

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 install Kodi 17.3 on Ubuntu 17.04, Ubuntu 16.04 & Linux Mint

Kodi 17.3 (Krypton) recently released, is a free open source media center for playing videos, music, pictures, games, and...
12/02/2020

Ubuntu Boot Partition Full

In this article, I am going to talk about problems you may have with your boot partition getting full and how you remedy...
29/12/2020

Install PHP5 Ubuntu

If you’ve tried to install PHP 5 on the latest release of Ubuntu (which is at of this writing Ubuntu 17.10), you know that...
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