![如何使用 `nmcli` 或 `dhcpcd` 释放(删除)之前连接到公共 WIFI 网络的路由?](https://linux22.com/image/160474/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20%60nmcli%60%20%E6%88%96%20%60dhcpcd%60%20%E9%87%8A%E6%94%BE%EF%BC%88%E5%88%A0%E9%99%A4%EF%BC%89%E4%B9%8B%E5%89%8D%E8%BF%9E%E6%8E%A5%E5%88%B0%E5%85%AC%E5%85%B1%20WIFI%20%E7%BD%91%E7%BB%9C%E7%9A%84%E8%B7%AF%E7%94%B1%EF%BC%9F.png)
一旦我连接到公共网络,一段时间(1-2 小时)后,我将无法访问互联网。我认为这是因为我的路由是使用公共路由器的 DHCP 提供的先前 IP 配置的。如何重新配置我的连接?这意味着我如何删除以前的路由并使其从 DHCP 请求新的 IP。但如果我重新启动它就可以工作(显示一个强制屏幕,然后显示互联网)。
[root@arch-pc art]# ip add
2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether [IDHERE] brd ff:ff:ff:ff:ff:ff
inet 192.168.205.14/24 brd 192.168.205.255 scope global dynamic noprefixroute wlp3s0
valid_lft 43155sec preferred_lft 43155sec
[root@arch-pc art]# ip route
default via 192.168.205.254 dev wlp3s0 proto dhcp metric 20600
192.168.205.0/24 dev wlp3s0 proto kernel scope link src 192.168.205.14 metric 600
[root@arch-pc art]# nmcli d disconnect wlp3s0
Device 'wlp3s0' successfully disconnected.
[root@arch-pc art]# nmcli d connect wlp3s0
Device 'wlp3s0' successfully activated with '40da5feb-1514-4b06-88bc-00491dadb1f3'.
[root@arch-pc art]# ip add
2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether [IDHERE] brd ff:ff:ff:ff:ff:ff
inet 192.168.205.14/24 brd 192.168.205.255 scope global dynamic noprefixroute wlp3s0
valid_lft 43195sec preferred_lft 43195sec
[root@arch-pc art]# dhcpcd --rebind wlp3s0
sending commands to master dhcpcd process
[root@arch-pc art]# curl http://1.1.1.1 -v
* Trying 1.1.1.1:80...
* TCP_NODELAY set
^C
[root@arch-pc art]# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
^C
--- 1.1.1.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 21ms
[art@arch-pc ~]$ nmcli -version
nmcli tool, version 1.20.0-1
答案1
你能尝试一下吗:
nmcli radio wifi off
几秒钟后
nmcli radio wifi on
看看是否有帮助?