In this tutorial, How to configure a static IP address on Linux. Step by step to make a static IP address on Linux.
Note: To change the network setting a good idea to make a copy of any configured file before your changes.
Table of Contents
Configure a static IP address on Linux
For RHEL 8
How to configure a static IP address on an RHEL system. using
$ nmcli dev status
Now, To change the network interface from dynamic to static, you need to edit the file in folder “/etc/
Configuring a static IP address as below
HWADDR=7C:67:2A:CC:DF:8F
ESSID=Comtrend7FB9
MODE=Managed
KEY_MGMT=WPA-PSK
SECURITYMODE=open
MAC_ADDRESS_RANDOMIZATION=default
TYPE=Wireless
IPADDR=192.168.3.4 # Ip address static for Linux server
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=Comtrend7FB9
UUID=3f5a6317-27c7-249f-bfaa-1d2fa5283482
ONBOOT=yes
Restarting NetworkManager.
$ sudo systemctl restart NetworkManager
For Ubuntu 18.10
Using
$ nmcli d
For example, configure a static IP address on the Ubuntu system.
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp0s25
iface enp0s25 inet static
address 192.168.3.4
netmask 255.255.255.0
network 192.168.3.1
broadcast 192.168.3.255
Restart the networking service.
$ sudo systemctl restart NetworkManager.service
Configure Static IP On CentOS 6
You can update/edit as follow static IP configure. For example, I will update for eth0 interface network.
HWADDR=00:08:A2:0B:BA:B7
TYPE=Ethernet
BOOTPROTO=none
# IP static for Server #
IPADDR=192.168.3.4
# Subnet #
PREFIX=24
# Set default gateway IP for server #
GATEWAY=192.168.3.1
# Set dns servers #
DNS1=192.168.3.1
DNS2=8.8.8.8
DNS3=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
# Disable ipv6 #
IPV6INIT=no
NAME=eth0
# This is system specific and can be created using 'uuidgen eth0' command #
UUID=31171a6f-bcg1-44de-8h6e-cf8e782f8bd6
DEVICE=eth0
ONBOOT=yes
Save and close the file. you need to restart the service network to apply the configure for the eth0 interface network.
$ sudo systemctl restart network
Conclusion
You have configure a static IP address on Linux. I hope will this your helpful. Thank you for reading the DevopsRoles page!