1.vim /etc/sysconfig/network-scripts/ifcfg-eth0 修改默认配置文件
TYPE=Ethernet BOOTPROTO=static #静态 可修改为【none|static|bootp|dhcp】(不使用协议|静态地址|BOOTP协议|DHCP协议) 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 IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 DEVICE=eth0 #物理设备名 ONBOOT=yes #修改为yes 激活网卡设备 IPADDR=192.168.100.13 #IP地址 PROFIX=24 #NETMASK=255.255.255.0 子网掩码 GATEWAY=192.168.100.1 #网关地址 DNS=114.114.114.114 ZONE=
2./etc/init.d/network restart 配置完毕重启网卡服务
[root@localhost ~]# /etc/init.d/network restart
Restarting network (via systemctl): [ 确定 ]
3.ifconfig 或 ip addr list/show 查看IP地址
无ifconfig命令可安装软件包 net-tools
yum install -y net-tools
4.vim /etc/sysconfig/ 修改DNS文件
增加 nameserver 114.114.114.114
# Generated by NetworkManager nameserver 114.114.114.114