https://www.cyberciti.biz/faq/howto-setting-rhel7-centos-7-static-ip-configuration/
I am a new sysadmin and CentOS user. My system is configured to use DHCP. How can I switch from DHCP to static IP address on CentOS 7 desktop system? How do I setup a static TCP/IP address on my CentOS Linux 7 or Red Hat Enterprise Linux 7 server using command line option?
On CentOS 7 or RHEL 7 one need to use the NetworkManager daemon. It attempts to make networking configuration and operation as painless and automatic as possible by managing the primary network connection and other network interfaces, like Ethernet, WiFi, and Mobile Broadband devices. In this quick tutorial you will learn about configuring a network interface with a static IP address using ifcfg files located in /etc/sysconfig/network-scripts/ directory in a CentOS 7 and RHEL 7:
Tutorial details |
---|
Difficulty level |
Root privileges |
Requirements |
Category |
OS compatibility |
Est. reading time |
Fig.01: List NICs in a CentOS 7 server using ip command
Or use the following command:
Fig.02: nmcli command in action
Here is a typical DHCP configration for eth0 (stored in /etc/sysconfig/network-scripts/ifcfg-eth0 file):
DEVICE="eth0"
ONBOOT=yes
NETBOOT=yes
UUID="41171a6f-bce1-44de-8a6e-cf5e782f8bd6"
IPV6INIT=yes
BOOTPROTO=dhcp
HWADDR="00:08:a2:0a:ba:b8"
TYPE=Ethernet
NAME="eth0"