HomeTutorialsHow to Configure Static IP Address on Linux System

How to Configure Static IP Address on Linux System

A Static IP address is a 32-bit identification address of your network that never changes where the dynamic IP address changes frequently. Establishing a dial-up internet connection through the PPPoE method is more straightforward than configuring an internet connection through a static IP address. The ISP could often provide you an IPv4 address, sub-netmask, and gateway address to establish your internet connection. Suppose you are a newbie on internet configuration and not familiar with a Linux system’s network manager. In that case, it could be a bit trickier to configure a static IP address on Linux-based systems.

Configure Static IP on Linux


If you are a gamer or have your public server on the internet, you might need to get a static IP to maintain the same IP for long-term usages. Before moving forward to see how to set up a static IP connection to a Linux system, you must ensure that you know the gateway, DNS, sub netmask, and the static IP that your ISP provided you.

Sometimes you might need to convert the subnet mask from prefix to dot-decimal notation. However, we will learn how you can configure a static IP connection on your Linux system.

1. Configure Static IP Address on Ubuntu/Debian Linux


Configuring a static IP connection on a Ubuntu or Debian Linux has two methods. The first one that I will describe is the command-line interface (CLI) method; later, I will describe the graphical user interface (GUI) process of configuring a static IP on Debian Linux.

Method 1: Configure Static IP via CLI


You can run the following netplan command on your terminal shell to edit the network configuration script. When the configuration script opens, enter your static IP, gateway, DNS, subnet mask, DHCP status, and other information that your ISP provided you inside the script, as shown in the picture below.

sudo netplan apply
sudo nano /etc/netplan/01-netcfg.yaml

static IP on Ubuntu Linux

Sample Of a Static IP configuration Script

network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.1.233/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]

After finishing the network configuration setting, you may now run the following command-lines on your shell to reload the network services.

sudo systemctl restart networking
systemctl status NetworkManager.service

Method 2: Configure a Static IP by GUI


This method will see how you can set up a static IP address on your Ubuntu Linux through your network settings’ graphical user interface. This method works for Ubuntu, Debian distributions, Fedora workstation, and other Gnome desktop environments.

First, open your Linux settings and find the Network setting. When the Network setting opens, you would see a picture as shown below. You can either set up a new connection or edit your existing network setting. Here, I will create a new connection. To create a new connection, click on the + (plus) icon, and you would see a new pop-up window opens.

static ip on ubuntu GUI

Now, click on the Ipv4 tab from the wired connection setting and mark the manual IPv4 method. You have to put your network configuration parameters on this dialog box. Put your static IP, subnet mask, gateway on the first row of the dialog box.

Then put your DNS server address on the second row; you can use multiple DNS addresses and separate them with commas. You can now click on the Apply button from the top right corner of the dialog box. After finishing the settings, click on the toggle button to activate the connection.

2. Static IP Address on Fedora Linux


There are three different methods to configure a static IP address on Fedora and Red Hat-based Linux system. Here, I will describe all of them. You can pick any of them to establish your internet connection.

Method 1: Configure a Static IP by NMCLI


On Fedora Linux, you can establish a network connection using a static IP with the command-line based network manager. The NMCLI settings are stored inside the /etc/NetworkManager/system-connections/ directory of your Linux filesystem.

However, you may run the following command-line given below on your Fedora terminal shell to know your network connection’s UUID. You have to note down the UUID; later, we will use the UUID to establish the internet connection.

sudo nmcli connection show

After running the above command, you would get the UUID of your wired connection, and the UUID should be a 32 bytes unique character.

c921602f-f1ff-4111-9c03-f04631632b16

nmcli on fedora

We can now use the UUID to configure our static IP address on a Fedora Linux. To establish the connection, you will need to know your static IP, subnet mask, gateway, and DNS address. If your subnet mask is in a dot-decimal method, you need to convert the subnet mask from dot-decimal (ex: 255.255.255.0) notation to prefix (ex: IP_Address/24) notation.

Now, run the following command-lines chronologically on the terminal shell of your Fedora Linux with root privileges.

$ sudo nmcli connection modify c921602f-f1ff-4111-9c03-f04631632b16 IPv4.address 192.168.1.127/24
$ sudo nmcli connection modify c921602f-f1ff-4111-9c03-f04631632b16 IPv4.gateway 192.168.1.1
$ sudo nmcli connection modify c921602f-f1ff-4111-9c03-f04631632b16 IPv4.dns 8.8.8.8
$ sudo nmcli connection modify c921602f-f1ff-4111-9c03-f04631632b16 IPv4.method manual

After running the above command-lines, you may now run the following commands to restart your internet connection.

$ sudo nmcli connection down c921602f-f1ff-4111-9c03-f04631632b16
$ sudo nmcli connection up c921602f-f1ff-4111-9c03-f04631632b16

Method 2: Configure a Static IP Address by CLI


This method will see how you can edit your network configuration script and configure a static IP address on your Linux system. You can run the following system configuration command to edit the network configuration script.

sudo nano /etc/sysconfig/network-scripts/ifcfg-enp2s0

Sample Of a static IP configuration script

NM_CONTROLLED="yes"
DEVICE="enp2s0"
BOOTPROTO=static
ONBOOT="yes"
IPADDR=1.2.3.4
NETMASK=255.255.255.0
GATEWAY=4.3.2.1
DNS1=114.114.114.114

When the configuration script opens, put your network parameters inside the script, then save and exit it. Your network configuration must contain a static IP, gateway, subnet mask, and DNS addresses.

static ip on fedora

Once your network configuration is done, you may now stop and start the device’s network manager.

# /etc/init.d/network stop
# /etc/init.d/network start

You can also run the following system control command to restart the network manager.

$ sudo systemctl restart network

Method 3: GUI Method of Configuring a Static IP


If you are using the Gnome DE on your Fedora Linux desktop, you may follow the graphical user interface method of establishing a static IP address on Ubuntu. The GUI method of configuring a static IP address on Ubuntu and Fedora workstation is moderately the same.

3. Static IP Address on Arch Linux


On Arch and Arch-based Linux systems, you can establish a static IP connection through the CLI and GUI methods. Here, I am using the Manjaro KDE to demonstrate the process of configuring a static IP address on an Arch Linux. All the following steps would work on other Arch Linux distributions as well.

Method 1: Configure Static IP Address by CLI Method


The command-line method is the most convenient method to configure a static IP on any Linux system. You can run the following systemd command on your terminal shell to edit and configure the network script.

sudo nano /etc/systemd/network/enp0s3.network

CLI on Arch for IP

After opening the network configuration script enter your IP address, gateway, subnet mask, and the DNS server address as shown below. Then save and exit the script.

[Match]
Name=enp0s3

[Network]
Address=192.168.1.10/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

You may now restart the network manager by disabling and enabling network services on your Linux system.

sudo systemctl disable --now NetworkManager.service
sudo systemctl enable --now systemd-networkd.service

Method 2: Establish Internet Connection by GUI Method


Arch and Arch-based Linux users can configure a static IP address on their system through the graphical user interface. First, go to the Connection settings on your Linux system and find the Wired Ethernet connection. Then click on the plus (+) button to add a new network. Now, click on the IPv4 tab to configure your static IP.

GUI on Manjaro Static Ip

Under the IPv4 tab, select the Manual method and enter your DNS server address, IP address, Netmask, and Gateway address. Then click on the Save button to finish the process.

ipv4 setting on Manjaro Arch

You can now restart your network manager to reload the new network on your Linux machine.

systemctl restart NetworkManager.service

Extra Tip: Configure A Router


Setting up a router is easy; you need to turn your router on and connect your router through a Lan cable with your PC. Now open your web browser and type the default gateway address of your router login page. Usually, the gateway address is 192.168.0.1. Here, I am using a TP-Link router, so the default username and the password would be admin. You would find the login information at the back of your router.

However, after logging in to your router, click on the quick setup button and choose the operation mode. Then select Static IP from the WAN Connection Type.

static IP quick setup TP Link

Now you have to fill up the blank boxes with your static IP address, subnet mask, default gateway, primary DNS server, and secondary DNS server address. Then click on the Next button and finish the router configuring process by setting up your wireless network SSID and password.

IP configuration on router

If you still can’t access the internet, there is a chance that the MAC address of your router is not registered and enabled by your ISP; you should contact your ISP to solve this issue.

Final Words


As a static IP address remains the same all the time, it is evident that you will get a stable connection with faster download and upload speed. Moreover, if you need to use any VoIP services, you would consider getting a static IP connection. The static IP address has some limitations as well. A static IP is less secured than a dynamic IP, and if your IP gets blocked on any website, it remains blocked forever as the IP never changes.

In the entire post, I have described the CLI and GUI methods of how you can configure a static IP address on a Linux system. I have also described the usefulness, limitations, and problems that you would find while configuring a static IP address on your Linux system.

If you find this post useful and informative, please share it with your friends and the Linux community. We also encourage you to write down your opinions regarding this post in the comment section.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.

LEAVE A REPLY

Please enter your comment!
Please enter your name here


You May Like It!

Trending Now