Home AntergosHow To Configure Static IP Address And Dynamic IP Address In Arch Linux

How To Configure Static IP Address And Dynamic IP Address In Arch Linux

By sk
Published: Updated: 0 views

Today, I have updated my Arch Linux test box. Once I rebooted my system, the network card doesn't work. I checked the network configuration file, and It's gone! I ran the "ip addr" command and noticed that the card is active and present, but configuration file has gone missing. If you ever been in this situation, don't panic. This brief tutorial addresses how to setup static IP address in Arch Linux and its derivatives like Antergos and Manjaro Linux etc. Not only static IP address, we will show you how to configure the Arch Linux to obtain IP address automatically from a DHCP server too. It's applicable for both newly installed system and already running system.

Here is what I did to fix this problem. As you might know, the sample network configuration files will be stored under /etc/netctl/examples/ location in Arch Linux.

ls /etc/netctl/examples/

Sample output:

bonding macvlan-dhcp tunnel wireless-wep
bridge macvlan-static tuntap wireless-wpa
ethernet-custom mobile_ppp vlan-dhcp wireless-wpa-config
ethernet-dhcp openvswitch vlan-static wireless-wpa-configsection
ethernet-static pppoe wireless-open wireless-wpa-static

sksk_002

As you see in the above output, ethernet-static and ethernet-dhcp files are the sample Ethernet profiles. You will also see the wireless network profiles too.

Configure Static IP Address In Arch Linux

First let us find the network card name using command:

ip addr

Sample output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
 valid_lft forever preferred_lft forever
 inet6 ::1/128 scope host
 valid_lft forever preferred_lft forever
 2:enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
 link/ether c0:18:85:50:47:4f brd ff:ff:ff:ff:ff:ff
 valid_lft forever preferred_lft forever
 inet6 fe80::b0f9:8a32:606d:3b27/64 scope link
 valid_lft forever preferred_lft forever

As you see in the above output, my network card name is enp5s0. Now, Copy the sample network card profile from /etc/netctl/examples/ directory to /etc/netctl/ directory as shown below.

sudo cp /etc/netctl/examples/ethernet-static /etc/netctl/enp5s0

Replace enp5s0 with your network card name.

Now, edit the network config file:

sudo nano /etc/netctl/enp5s0

Enter your IP address, Netmask, gateway, and DNS server details as shown below.

Description='A basic static ethernet connection'
Interface=enp5s0
Connection=ethernet
IP=static
Address=('192.168.43.200/24')
Gateway=('192.168.43.1')
DNS=('8.8.8.8' '8.8.4.4')

You must replace eth0 with your actual network card name (i.e enp5s0) in the above configuration file. Save and close the file.

Enable the network card to start automatically on every reboot with command:

sudo netctl enable enp5s0

Finally, start the network profile as shown below.

sudo netctl start enp5s0

Restart your system. Now, the network card should work. Please note that this will work only on systems that network card has a working network , but the network config file is missing. If the network card is not detected, then it's different case.

Configure Auto IP Address (DHCP) In Arch Linux

Now, Copy ethernet-dhcp profile from /etc/netctl/examples/ directory to /etc/netctl/ directory as shown below.

sudo cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/enp5s0

Edit /etc/netctl/enp5s0 file and replace eth0 with your actual network interface name i.e enp5s0. Save and close the file.

Enable and start the network interface card:

sudo netctl enable enp5s0
sudo netctl start enp5s0

Reboot your system. The network card must work now.

That's all for now folks. Hope this guide will help you.

Cheers!

Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More