RHEL7.x version, set three methods IP address, gateway and DNS

RHEL7.x versions, naming card from eth0,1,2 became enoxxxx format. Wherein en for Enthernet (Ethernet card), O represents Onboard (built-in), that string is automatically generated by the digital board index number. And compared to the original naming scheme, the disadvantage is too long and difficult to remember, is the number of unique advantages, not error-prone systems migration. How that set ip address, gateway and dns it? The following describes three commonly used methods.
Method 1:
Modify the network card configuration file

[root@ys ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728
YPE=Ethernet
BOOTPROTO=static || none          //启用静态IP地址,BOOTPROTO=dhcp,启用动态获取
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes || no          //是否支持IPV6
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728          //设备名称
UUID=f248e89a-6788-489f-a236-a401ff596a38          //设备标识号
DEVICE=eno16777728          //设备名称
ONBOOT=yes          //是否启动启动网络连接
IPADDR=192.168.1.100         //设置IP地址
PREFIX=24          //设置子网掩码长度
GATEWAY=192.168.1.1          //设置网关
DNS1=12.3.1.1          //设置DNS
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

Method 2:
Use nmtui command, as shown below
[root@ys 桌面]# nmtui
RHEL7.x version, set three methods IP address, gateway and DNS
RHEL7.x version, set three methods IP address, gateway and DNS
RHEL7.x version, set three methods IP address, gateway and DNS

Method 3:
Use the command nm-connection-editor, as shown below
[root@ys 桌面]# nm-connection-editor
RHEL7.x version, set three methods IP address, gateway and DNS
RHEL7.x version, set three methods IP address, gateway and DNS
RHEL7.x version, set three methods IP address, gateway and DNS

Finally, restart card services, the changes to take effect
[root@ys ~]# systemctl restart network

Guess you like

Origin blog.51cto.com/yuanshuai/2468218