Centos7固定IP
2017-04-04 本文已影响0人
liurongming
查看当前网络
# 查看网络状态
# service network status
# 查看用法
# service network
用法:/etc/init.d/network {start|stop|status|restart|reload|force-reload}
或者使用`systemctl`
# 查看网络状态
# systemctl status network.service
# 重启网卡
# systemctl restart network.service
# 刷新网络配置
# systemctl reload network.service
# 启动网卡
# systemctl start network.service
选择网卡
# cd /etc/sysconfig/network-scripts/
[root@centos7 network-scripts]# ls
ifcfg-eth0 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-wireless network-functions
ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifup ifup-eth ifup-isdn ifup-post ifup-sit init.ipv6-global network-functions-ipv6
ifdown ifdown-ippp ifdown-post ifdown-sit ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-tunnel net.hotplug
打开网卡
# vim ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=43526aeb-1c5e-4bfc-8382-3ac1313db9c4
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.0.18
PREFIX=24
GATEWAY=192.168.0.1
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:E0:4C:05:98:91
LAST_CONNECT=1488087337