1、编辑 ifcfg-eth0 文件,vim 最小化安装时没有被安装,需要自行安装不描述。
#vim/etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO="static"#dhcp改为static ONBOOT="yes"#开机启用本配置 IPADDR=172.16.13.40#静态IP GATEWAY=172.16.13.254#默认网关 NETMASK=255.255.255.0#子网掩码 DNS1=172.16.10.1#DNS配置
#]#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=172.16.13.40#静态IP GATEWAY=172.16.13.254#默认网关 NETMASK=255.255.255.0#子网掩码 DNS1=172.16.10.1#DNS配置
4、重启下网络服务
#servicenetworkrestart
5、查看改动后的效果,Centois 7 不再使用 ifconfig 而是用 ip 命令查看网络信息。
#ipaddr 1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWN link/loopback00:00:00:00:00:00brd00:00:00:00:00:00 inet127.0.0.1/8scopehostlo valid_lftforeverpreferred_lftforever inet6::1/128scopehost valid_lftforeverpreferred_lftforever 2:eth0:<BROADCAST,MULTICAST,LOWER_UP>mtu1500qdiscpfifo_faststateUNKNOWNqlen1000 link/ether00:15:5d:07:f1:02brdff:ff:ff:ff:ff:ff inet172.16.13.40/24brd172.16.13.255scopeglobaleth0 valid_lftforeverpreferred_lftforever inet6fe80::215:5dff:fe07:f102/64scopelink valid_lftforeverpreferred_lftforever