Configure Static IP Address on Arch Linux via command line

Arch Linux Tutorial - Hello everyone, today I am going to show you how to configure static IP address on Arch Linux 2017 via command line. I assume you have direct access to Arch Linux and a basic understanding of Linux commands. This tutorial will cover only for ethernetc connection. Next time I will show you how to configure WiFi connection on Arch Linux.

arch

Arch Linux comes with built in network configuration samples located in /etc/netctl/examples. We will use this sample and modify a little bit for our system.

ls /etc/netctl/examples

Output:

root@archiso ~ # ls /etc/netctl/examples
bonding          ethernet-static  openvswitch  vlan-dhcp      wireless-wpa
bridge           macvlan-dhcp     pppoe        vlan-static    wireless-wpa-config
ethernet-custom  macvlan-static   tunnel       wireless-open  wireless-wpa-configsection
ethernet-dhcp    mobile_ppp       tuntap       wireless-wep   wireless-wpa-static

As you can see, we have ethernet-dhcp and ethernet-static that can be used to configure our ethernet connection. Now we need to find our network card name.

ip link

Output

root@archiso ~ # ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 36:3a:d8:6a:4b:8a brd ff:ff:ff:ff:ff:ff

As you can see from the output above, my network card is ens18. Replace ens18 with your network card name. Now copy the configuration sample.

cp /etc/netctl/examples/ethernet-static /etc/netctl/ens18

Now we need to edit the new config file we just created

nano /etc/netctl/ens18

Original Output:

Description='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.1.23/24' '192.168.1.87/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.1.1'
DNS=('192.168.1.1')

## For IPv6 autoconfiguration
#IP6=stateless

## For IPv6 static address configuration
#IP6=static
#Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
#Routes6=('abcd::1234')
#Gateway6='1234:0:123::abcd'

After made some changes, here is my configuration file looks like (I deleted some unused lines)

Description='A basic static ethernet connection'
Interface=ens18
Connection=ethernet
IP=static
Address=('10.34.0.102/24')
Gateway='10.34.0.1'
DNS=('10.34.0.10')

Do not forget to replace eth0 with your network card name (ens18 in my case).

Now enable the network card upon boot

netctl enable ens18

Stop network and then start the network profile

ip link set ens18 down
netctl start ens18

Stop and disable dhcpcd service

systemctl stop dhcpcd
systemctl disable dhcpcd



EmoticonEmoticon