有很多小白在配置后静态Ip之后,
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR=192.168.135.145
NETMASK=255.255.255.0
GATEWAY=192.168.135.2
DNS1=114.114.114.114
过段时间重启就会发现网络无法连接,静态Ip失效;
查看ip addr 时是这个给样子的
[zzy@localhost ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:0c:29:68:c8:16 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:af:c1:75 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:af:c1:75 brd ff:ff:ff:ff:ff:ff
这个时候可以查看一下网卡链接状态,有可能在这之前你需要先开启一下网络管理服务
systemctl start NetworkManager
或者
systemctl restart NetworkManager
然后查看网卡服务状态-----
[zzy@localhost ~]$ nmcli device
DEVICE TYPE STATE CONNECTION
virbr0 bridge unmanaged --
ens160 ethernet unmanaged --
lo loopback unmanaged --
virbr0-nic tun unmanaged --
都处于未管理状态–此时将管理服务打开
确认一下网卡管理状态—>>
nmcli n
disabled
开启网卡管理状态
nmcli n on
再次查看网卡管理状态
nmcli n
enabled
nmcli device
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
virbr0 bridge unmanaged --
lo loopback unmanaged --
virbr0-nic tun unmanaged --
ip addr 查看ip
[zzy@localhost ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:68:c8:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.135.145/24 brd 192.168.135.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
inet6 fe80::f1ff:ba15:28b7:8b3a/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:af:c1:75 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 52:54:00:af:c1:75 brd ff:ff:ff:ff:ff:ff