如何使用 `nmcli` 或 `dhcpcd` 释放(删除)之前连接到公共 WIFI 网络的路由?

如何使用 `nmcli` 或 `dhcpcd` 释放(删除)之前连接到公共 WIFI 网络的路由?

一旦我连接到公共网络,一段时间(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

看看是否有帮助?

相关内容