linux真机系统连了wifi但上不了网?
Posted Tuki_a
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux真机系统连了wifi但上不了网?相关的知识,希望对你有一定的参考价值。
今天开机后连接自己的wifi,发现不能上网,删除了几个wifi的网卡配置文件重启了几次还是不行。
逐一排查:
先查看下网关
[root@foundation26 ~]# route -n
可以看到本来是应该路由到我wifi的192的网关,但现在首先是路由到172这个网关上了,那自然是上不了网的!
上面说明我的主机会自动给我添加静态网关,我先手动把他删掉
[root@foundation26 html]# route del default gw 172.25.254.254
[root@foundation26 html]# route -n
然后到配置文件删除静态网关route-br0
[root@foundation26 html]# cd /etc/sysconfig/network-scripts/
[root@foundation26 network-scripts]# ls
ifcfg-br0 ifcfg-westoslinux keys-Hello,world!
ifcfg-enp0s25 ifcfg-Wired_connection_1 keys-westoslinux
ifcfg-Hello,world! ifcfg-Wired_connection_2 route-br0
[root@foundation26 network-scripts]# cat route-br0
172.25.0.0/16 via 172.25.254.254
[root@foundation26 network-scripts]# rm -f route-br0
查看ip可以看到enp0s25有线网卡有ip,本来应该没ip的,桥接出去了,但现在有线网卡有ip说明桥接有问题(wlp3s0是无线网卡)
[root@foundation26 network-scripts]# ip addr
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:21:cc:65:b4:fc brd ff:ff:ff:ff:ff:ff
inet 172.25.254.231/24 brd 172.25.254.255 scope global dynamic noprefixroute enp0s25
valid_lft 100sec preferred_lft 100sec
inet6 fe80::3b4f:f170:1ccc:eb64/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether a0:88:b4:c6:6d:0c brd ff:ff:ff:ff:ff:ff
inet 192.168.92.27/24 brd 192.168.92.255 scope global dynamic noprefixroute wlp3s0
valid_lft 2322sec preferred_lft 2322sec
inet6 2409:8970:b20:56a3:307a:d63d:5d8a:75ef/64 scope global dynamic noprefixroute
valid_lft 3393sec preferred_lft 3393sec
inet6 fe80::70c4:f917:1607:cc5e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
看下现有连接,多余的down掉并删掉
[root@foundation26 network-scripts]# nmcli connection show
NAME UUID TYPE DEVICE
Bridge br0 d2d68553-f97e-7549-7a26-b34a26f29318 bridge br0
Hello,world! a0a08aec-db1c-48a3-9bcf-b704b58fa67b wifi wlp3s0
privbr0 a71ea69f-60f8-4f8a-a3d2-6890633353d7 bridge privbr0
virbr0 5d78ae2a-bbfe-4f73-ae4b-0894eb593f26 bridge virbr0
virbr1 2adf777b-6853-47cd-983c-7df7f3e68319 bridge virbr1
virbr1-nic 8576c357-6c59-4eb9-b22c-168c0258c6a4 tun virbr1-nic
vnet0 c8bf288c-bc4a-4d83-9d6b-c6a36706e330 tun vnet0
vnet1 65738d6a-d9a3-4715-921d-cc6fd4185cf3 tun vnet1
Wired connection 2 31f046b5-7056-4e8a-a965-0e5ba1f30624 ethernet enp0s25
System enp0s25 939b168c-2e8b-4fd3-bdb8-35b1324832e8 ethernet --
westoslinux 9939cf35-f0f8-43db-bf4d-8c9ea65a0802 wifi --
Wired connection 1 4b8a6f41-a9d9-4d3c-a544-2bf8c9cb2e6f ethernet --
[root@foundation26 network-scripts]# nmcli connection down Wired\\ connection\\ 2
Connection 'Wired connection 2' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)
[root@foundation26 network-scripts]# nmcli connection delete Wired\\ connection\\ 2
Connection 'Wired connection 2' (31f046b5-7056-4e8a-a965-0e5ba1f30624) successfully deleted.
[root@foundation26 network-scripts]# nmcli connection delete Wired\\ connection\\ 1
Connection 'Wired connection 1' (4b8a6f41-a9d9-4d3c-a544-2bf8c9cb2e6f) successfully deleted.
[root@foundation26 network-scripts]# nmcli connection delete westoslinux
Connection 'westoslinux' (9939cf35-f0f8-43db-bf4d-8c9ea65a0802) successfully deleted.
[root@foundation26 network-scripts]# ls
ifcfg-br0 ifcfg-enp0s25 ifcfg-Hello,world! keys-Hello,world!
## 现在连接环境就比较干净了,只剩下了我的wifi和桥接以及网卡配置
再查看ip如下显示已经桥接到br0上了,恢复正常
[root@foundation26 network-scripts]# ip addr
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether 00:21:cc:65:b4:fc brd ff:ff:ff:ff:ff:ff
然后测试,百度可以ping通,网关、网桥、域名解析、网桥配置文件ifcfg-br0都没有问题
[root@foundation26 network-scripts]# bridge link
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100
6: privbr0-nic: <BROADCAST,MULTICAST> mtu 1500 master privbr0 state disabled priority 32 cost 100
8: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 master virbr0 state disabled priority 32 cost 100
10: virbr1-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master virbr1 state disabled priority 32 cost 100
11: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100
12: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100
[root@foundation26 network-scripts]# ping baidu.com
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=50 time=37.8 ms
^C
--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 37.795/37.795/37.795/0.000 ms
[root@foundation26 network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.92.239 0.0.0.0 UG 600 0 0 wlp3s0
172.25.0.0 172.25.254.254 255.255.0.0 UG 425 0 0 br0
172.25.26.0 0.0.0.0 255.255.255.0 U 425 0 0 br0
172.25.250.0 0.0.0.0 255.255.255.0 U 0 0 0 privbr0
172.25.254.0 0.0.0.0 255.255.255.0 U 425 0 0 br0
192.168.92.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp3s0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@foundation26 network-scripts]# cat /etc/resolv.conf
# Generated by NetworkManager
search ilt.example.com example.com
nameserver 2409:8970:b20:56a3::92
nameserver 192.168.92.239
nameserver 172.25.254.250
至此问题解决!
以上是关于linux真机系统连了wifi但上不了网?的主要内容,如果未能解决你的问题,请参考以下文章