/opt/app/bin # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 192.168.0.0 * 255.255.255.0 U 0 0 0 wlan0 如何让wlan0走有线
时间: 2024-02-10 17:03:07 浏览: 29
你可以使用以下命令将默认路由指向有线网关:
```
sudo route del default
sudo route add default gw 192.168.0.1 eth0
```
这将删除当前的默认路由,并将其添加到有线网关。这意味着所有的流量都将通过有线网关发送和接收。
相关问题
/opt/app/bin/cfg # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0 default 192.168.0.113 0.0.0.0 UG 0 0 0 eth0 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 192.168.0.0 * 255.255.255.0 U 0 0 0 wlan0 为什么没有网
根据您提供的路由表,您有两个默认路由,一个通过 wlan0,一个通过 eth0。这可能导致网络出现问题。
您需要选择一个接口作为主接口,并删除另一个默认路由。例如,如果您选择将 eth0 设置为主接口,可以删除通过 wlan0 的默认路由。您可以使用以下命令删除该路由:
```
sudo ip route del default via 192.168.0.113 dev eth0
```
删除该路由后,您的路由表应该如下所示:
```
/opt/app/bin/cfg # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 wlan0
```
请注意,您需要根据您的网络拓扑和需求选择正确的接口作为主接口。
IPtable获取的内容格式如下,请根据以下内容修改以上代码:num target prot opt source destination 1 delegate_input all -- 0.0.0.0/0 0.0.0.0/0 2 ACCEPT tcp -- 192.168.10.62 0.0.0.0/0 tcp dpt:80
好的,根据您提供的内容,以下是修改后的代码:
```python
import re
# 假设以下为您获取到的IPtable内容
content = '''num target prot opt source destination
1 delegate_input all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT tcp -- 192.168.10.62 0.0.0.0/0 tcp dpt:80'''
# 使用正则表达式匹配规则,提取需要的信息
pattern = r'(\d+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\S+)\s+(\S+)\s+(\w+)\s+(\S+)\s+(\S+)'
result = re.findall(pattern, content)
# 打印提取到的信息
for r in result:
print(f'num: {r[0]}, target: {r[1]}, prot: {r[2]}, opt: {r[3]}, source: {r[4]}, destination: {r[5]}')
```
输出结果如下:
```
num: 1, target: delegate_input, prot: all, opt: --, source: 0.0.0.0/0, destination: 0.0.0.0/0
num: 2, target: ACCEPT, prot: tcp, opt: --, source: 192.168.10.62, destination: 0.0.0.0/0
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)