我有两个网络接口wlan0
和usb0
一个运行 Ubuntu 的 RaspberryPi。它们都连接到互联网。
我正在编写一个 python 脚本来在wlan0
. 当一个请求被发送到我的 pi 时,我将发送另一个请求到usb0
,响应数据将被发送回原始请求的来源。
当我尝试通过 发送测试请求时wlan0
,它确实按预期工作。但是当我尝试usb0
改用时,它不起作用
ifconfig
输出:
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether dc:a6:32:46:16:87 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
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 1000 (Local Loopback)
RX packets 120 bytes 9012 (9.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 120 bytes 9012 (9.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.42.208 netmask 255.255.255.0 broadcast 192.168.42.255
inet6 fe80::54e4:31ff:fe59:90d9 prefixlen 64 scopeid 0x20<link>
ether 56:e4:31:59:90:d9 txqueuelen 1000 (Ethernet)
RX packets 8 bytes 1428 (1.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 2008 (2.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.195 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::dea6:32ff:fe46:1688 prefixlen 64 scopeid 0x20<link>
inet6 2402:800:6116:a8ae:dea6:32ff:fe46:1688 prefixlen 64 scopeid 0x0<global>
ether dc:a6:32:46:16:88 txqueuelen 1000 (Ethernet)
RX packets 464 bytes 57446 (57.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 394 bytes 65085 (65.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
路由表:
default via 192.168.1.1 dev wlan0
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.195 metric 600
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.195
192.168.1.1 dev wlan0 proto dhcp scope link src 192.168.1.195 metric 600
192.168.42.0/24 dev usb0 proto kernel scope link src 192.168.42.208
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.1.0 dev wlan0 table local proto kernel scope link src 192.168.1.195
local 192.168.1.195 dev wlan0 table local proto kernel scope host src 192.168.1.195
broadcast 192.168.1.255 dev wlan0 table local proto kernel scope link src 192.168.1.195
broadcast 192.168.42.0 dev usb0 table local proto kernel scope link src 192.168.42.208
local 192.168.42.208 dev usb0 table local proto kernel scope host src 192.168.42.208
broadcast 192.168.42.255 dev usb0 table local proto kernel scope link src 192.168.42.208
::1 dev lo proto kernel metric 256 pref medium
2402:800:6116:a8ae::/64 dev wlan0 proto ra metric 600 expires 86355sec pref medium
fe80::/64 dev wlan0 proto kernel metric 256 pref medium
fe80::/64 dev usb0 proto kernel metric 256 pref medium
default via fe80::1 dev wlan0 proto ra metric 600 expires 1755sec pref low
local ::1 dev lo table local proto kernel metric 0 pref medium
local 2402:800:6116:a8ae:dea6:32ff:fe46:1688 dev wlan0 table local proto kernel metric 0 pref medium
local fe80::54e4:31ff:fe59:90d9 dev usb0 table local proto kernel metric 0 pref medium
local fe80::dea6:32ff:fe46:1688 dev wlan0 table local proto kernel metric 0 pref medium
ff00::/8 dev wlan0 table local metric 256 pref medium
ff00::/8 dev usb0 table local metric 256 pref medium
对不起,如果我问的是一个愚蠢的问题,我对这个网络东西完全是个菜鸟......