Raspbian重启网络无需重启

Raspbian重启网络无需重启

当我使用带有 4g USB 调制解调器的 raspbian 时,有时网络会出现故障,除非重新启动 raspbian,否则无法恢复网络。

在这种情况下,我尝试:

service networking restart

每小时执行一次 cron;这是行不通的。

我也尝试过ifdown -a && ifup -a——也好不了多少。

问题是,当我在终端中执行这些命令时,没有任何输出。

有什么办法可以让我重新启动网络?

root@raspberrypi:/home/pi# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::48f5:e07c:1544:2d24  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:38:6e:29  txqueuelen 1000  (Ethernet)
        RX packets 23902  bytes 8949877 (8.5 MiB)
        RX errors 0  dropped 17  overruns 0  frame 0
        TX packets 30039  bytes 6388288 (6.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Boucle locale)
        RX packets 20996  bytes 8495857 (8.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20996  bytes 8495857 (8.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:27:eb:6d:3b:7c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

答案1

我发现在 Raspbian 上唯一有效的是:

sudo ifconfig wlan0 down && sleep 5 && sudo ifconfig wlan0 up

相关内容