Few days before I posted how to install Arch Linux machine, Now we are going to see HowTo Configure Static And Dynamic IP Address In Arch Linux.

For this we are using latest arch Linux as of now Nov 2017

[root@archlinux ~]# uname -r
4.13.12-1-ARCH

Dynamic IP Address

After installation of Arch Linux machine, I need to connect machine from outside serial console or tty, So i need connectivity and SSH package install and running over this machine. So i need IP address configured on machine. I checked, but there was no IP address assigned on machine. So i though to use DHCP to configure IP address. Yes it works below mentioned below.

[root@archlinux ~]# ip addr list ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:a6:58:86 brd ff:ff:ff:ff:ff:ff

[root@archlinux ~]# dhcpcd ens3
ens3: waiting for carrier
ens3: carrier acquired
DUID 00:01:00:01:21:a6:2c:dc:52:54:00:a6:58:86
ens3: IAID 00:a6:58:86
ens3: adding address fe80::9206:ae35:e3b:7983
ens3: soliciting a DHCP lease
ens3: soliciting an IPv6 router
ens3: offered 192.168.122.148 from 192.168.122.1
ens3: probing address 192.168.122.148/24
ens3: leased 192.168.122.148 for 3600 seconds
ens3: adding route to 192.168.122.0/24
ens3: adding default route via 192.168.122.1
forked to background, child pid 501
[root@archlinux ~]# ip addr list ens3
2: ens3:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:a6:58:86 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.148/24 brd 192.168.122.255 scope global ens3
       valid_lft forever preferred_lft forever
    inet6 fe80::9206:ae35:e3b:7983/64 scope link 
       valid_lft forever preferred_lft forever

With above command, i am able to assign IP address on Arch Linux machine and able to connect network to and via this machine but in case i like to assign static IP address to this machine, for this i used to create a profile and assigned. Actually in Arch Linux, there is no network-scripts as they are present in Linux like RedHat/CentOS for static assignment.

So i created a file /etc/netctl/my_static_profile and start this profile with command netctl and enable it like below.

[root@archlinux ~]# cat /etc/netctl/my_static_profile
Interface=ens3
Connection=ethernet
IP=static
Address=('192.168.122.111/24')
Gateway=('192.168.122.1')
DNS=('192.168.122.1')

[root@archlinux ~]# ip addr list ens3
2: ens3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 52:54:00:a6:58:86 brd ff:ff:ff:ff:ff:ff

[root@archlinux ~]# netctl start my_static_profile

[root@archlinux ~]# ip addr list ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:a6:58:86 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.111/24 brd 192.168.122.255 scope global ens3
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fea6:5886/64 scope link 
       valid_lft forever preferred_lft forever

[root@archlinux ~]# netctl enable my_static_profile
ln -s '/etc/systemd/system/netctl@my_static_profile.service' '/etc/systemd/system/multi-user.target.wants/netctl@my_static_profile.service'

With above simple steps we can assign static IP address on Arch Linux machine.