How to configure IP in Linux?
IP address configuration
rhel7/centos7 has added a new IP address configuration tool, but the previous old version did not, so here are two methods you can refer to .
Method 1: nmcli tool (available in new version of the system)
Step 1 Check the network card name
[root@localhost Desktop]# nmcli connection
As shown in the figure, NAME corresponds to the name of the network card, and DEVICE corresponds to the hardware identification of the network card. The name can be modified.
The one starting with vir is a virtual network card or virtual device, so the network card address starting with eno needs to be configured here.
Step 2 Configure IP address
[root@localhost Desktop]# nmcli connection modify "eno16777736" ipv4.addresses "172.20.10.3/24" 地址及掩码 [root@localhost Desktop]# nmcli connection modify "eno16777736" ipv4.gateway "172.20.10.1" 网关 [root@localhost Desktop]# nmcli connection modify "eno16777736" ipv4.dns "114.114.114.114" 域名服务器 [root@localhost Desktop]# nmcli connection modify "eno16777736" ipv4.method manual 手动而不是DHCP [root@localhost Desktop]# nmcli connection modify "eno16777736" connection.autoconnect yes 开机启动 [root@localhost Desktop]# nmcli connection up "eno16777736" 开启接口
Step 3 View IP address and test
Method 2: Via vi Editor to edit the network card configuration file (systems below RHEL7)
[root@localhost Desktop]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
Modify the corresponding information in the picture below
Press i to enter the editing mode
Press esc Then enter: wq to save and exit
Press esc and then enter: q! to exit without saving
After the modification is completed, restart the network service through service network restart
Recommended: "Linux Tutorial"
The above is the detailed content of How to configure IP in linux. For more information, please follow other related articles on the PHP Chinese website!