How to Configure Static IP in Arch Linux

Simply, static IP can be defined as a non-changing internet address. Static IP can tell the location of the computer to other computers or servers on the internet. This article will help you to configure a static IP address in Arch Linux using netctl. Netctl is a command-line utility for managing the network profile in Linux.

Let’s begin with installing the netctl if not installed.

$ sudo pacman -S netctl

We can verify the installation by checking the version of netctll using the following command.

$ netctl --version

netctl-command-arch-linux

Before configuring the netctl profile, we must first distinguish the following things from our system.

1) Network Interface

Network Interface is the hardware or software component that connects the computer with the internet. We need the network interface name for configuring the static IP address. We can fetch the network interface using the following command.

$ ip addr

In my context, the network interface name is eth0.

Ip-addr-Command-output-Arch-Linux

2)  Gateway

Gateway is the point that acts as a gate between two networks such as a router. We can get the gateway address using the IP route command. It will display the IP of the gateway from where your computer gets connected to another network.

$ ip route

In the output, the gateway address is the first IP address after default via.

Check-Default-Gateway-ArchLinux

3) DNS

Domain Name System (DNS) helps in translating the domain name into a machine-readable IP address. It can also define as an internet phone book. In the scenario, I used my default gateway address as the primary DNS and google public DNS addresses (8.8.8.8, 8.8.4.4 ) as secondary and tertiary DNS respectively. If you want you can use only google public DNS address(8.8.8.8 or 8.8.4.4).

4)  Configuring netctl Network Profile

The netctl provides a sample file for static network configuration in an ethernet-static file which is located at /etc/netctl/examples/. We need to copy this file in /etc/netctl/ and name it according to your network interface name. In my case, it’s eth0 so, I will copy the file as eth0. The cp command will rename the file if we mention the file name along with the destination.

$ sudo cp  /etc/netctl/ethernet-static /etc/netctl/eth0

After copying the file open the newly copied file in any editor.

$ sudo vi /etc/netctl/eth0

Now, change the interface named eth0 to your actual interface name, address with your desire static IP address, gateway to your actual gateway address, and lastly DNS to google public DNS or other. In my context, I used the current used IP for configuring static IP.

Lastly, we need to enable and start the newly configure network profile for this we need to execute the following commands.

To enable your network profile using the netctl command.

$ sudo netctl enable eth0

Then, start the network profile.

$ sudo netctl start eth0

5) DHCP

DHCP states as Dynamic Host Configuration Protocol which is used in IP as a network management protocol. Using DHCP protocol DHCP server provides a unique IP to the device that is connected to the internet. By default DHCP is configured in the Linux System so, we need to disable it as it provides dynamic IP to the device. In absence of a DHCP network administrator assign static IP to the device that has internet access. For disabling DHCP execute the following command.

First, we need to stop the DHCP service.

$ sudo systemctl stop dhcpcd

Then, we need to disable DHCP as it is enabled by default.

$ sudo systemctl disable dhcpcd

You need to reboot the system to apply the changes.

Now check the IP address and ping some domain name(google.com) to verify if the configuring static IP address is working or not.

$ ip addr
$ ping google.com

Conclusion

I hope this article might be helpful in configuring the static IP in arch Linux. We can also configure static IP addresses using System Manager but I prefer using netctl as it is much easier to configure or manage network services.

Also Read11 rsync command examples for Linux Beginners

Leave a Comment

12 + twelve =