Setup Static IP
Who is this for?
- You run a server with no need for a DHCP client IP lease
- You don't have any wireless/wifi interfaces
- You need to set a static IP on your ethernet interfaces, either because: the current IP config is using DHCP, or the current static IP config is outdated/broken
- Your server runs without a GUI, so CLI tools need to be used
Warning : You should have local/console access to this server, as attempting to do this remotely will almost certainly break your network connection to the server.
Some sections have been modified from other Pages in Manjaro Linux Wiki.
Gather important information
Determine what ethernet interface you need to configure:
# ip addr Your interfaces may be named in the style of the old way - eth0 Or the new - enp0s11 Make a note of this and modify your commands/entries accordingly - this is critically important.
Flush IP Config and Disable Services
Enter following code to bring down the interface and flush it's current IP config:
# sudo ifcfg enp0s11 stop # sudo ip link set enp0s11 down # sudo ip addr flush enp0s11
Enter following code to disable DHCP client daemon and Network Manager service:
# sudo systemctl stop dhcpcd # sudo systemctl disable dhcpcd # sudo systemctl stop NetworkManager # sudo systemctl disable NetworkManager
We have no need for Network Manager since we will be using netctl
Let's backup resolv.conf :
# cd /etc # sudo cp ./resolv.conf ./resolv.conf.bak
And clear out all entries in it:
# sudo nano ./resolv.conf
(clear out all entries, exit nano, save changes)
We will put our DNS search domain and DNS name servers elsewhere, which will auto-update /etc/resolv.conf
Know that /etc/resolv.conf is overwritten every time your machine boots up.
Create/Modify Profile for Interface
Let's copy the example netctl profile:
# cd /etc/netctl # sudo cp examples/ethernet-static ./enp0s11
And make/update our netctl profile for this interface:
# sudo nano ./enp0s11
Description='enp0s11' Interface=enp0s11 Connection=ethernet AutoWired=yes SkipNoCarrier=yes IP=static Address=('192.168.1.14/24') Gateway='192.168.1.1' Hostname='server' DNS=('192.168.1.11' '192.168.1.12') DNSDomain='domain.local' DNSSearch='domain.local'
(exit nano, save changes)
Load/Reload Profile for Interface
Enter following code if you just now created the interface's netctl profile:
# sudo netctl enable enp0s11 # sudo netctl start enp0s11
Or enter following code if you updated the interface's netctl profile:
# sudo netctl reenable enp0s11 # sudo netctl restart enp0s11
Bring Up the Interface
Enter following code to bring up the interface:
# sudo ip link set enp0s11 up # sudo ifcfg enp0s11 start
(you might also need to reboot for changes to take effect)
You have now configured a static IP that should: survive reboots, survive reboots without ethernet cable plugged in, and it won't even attempt getting a DHCP lease.