Original link: https://blog.csdn.net/lsm135/article/details/51824132#commentBox
1, file edit ifcfg-eth0, is not installed vim minimize installation, you need not install their own description.
2, the following modifications
1 BOOTPROTO = " static " #dhcp changed to static 2 ONBOOT = " yes " # boot configuration to enable this 3 IPADDR = 192.168 . 197.131 # static IP 4 GATEWAY = 192.168 . 197.2 # Default Gateway 5 NETMASK = 255.255 . 255.0 # subnet mask code . 6 the DNS1 = 192.168 . 197.2 #DNS configuration
3, the effect of the modified
[root@root123 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 HWADDR="00:15:5D:07:F1:02" TYPE="Ethernet" BOOTPROTO="static" #dhcp改为static DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_FAILURE_FATAL="no" NAME="eth0" UUID="bb3a302d-dc46-461a-881e-d46cafd0eb71" ONBOOT="yes" #开机启用本配置 IPADDR=192.168.197.131#静态IP GATEWAY=192.168.197.2 # default gateway NETMASK = 255.255 . 255.0 # subnet mask DNS1 = 192.168 . 197.2 #DNS Configuration
4, under the Network Service Restart
[root@root123 ~]# service network restart
5, after the effect of view changes, Centois 7 but no longer use ifconfig ip command to view network information.
[root@root123 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether 00:0c:29:b3:a8:5e brd ff:ff:ff:ff:ff:ff inet 192.168.197.131/24 brd 192.168.197.255 scope global eth0 inet 192.168.197.129/24 brd 192.168.197.255 scope global secondary eth0 inet6 fe80::20c:29ff:feb3:a85e/64 scope link valid_lft forever preferred_lft forever