Set a Static IP Address on Linux (IPv4)
To configure a static IPv4 address on a Linux system, you need to edit the /etc/network/interfaces file.
Editing the configuration file
Use a text editor like nano to open the file:
nano /etc/network/interfaces
Here’s a valid example of a static IPv4 configuration:
# IPv4 address
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
DNS configuration
To configure DNS servers, edit the /etc/resolv.conf file:
nano /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
Restart networking services
After applying changes, restart networking with the following command:
service networking restart