0

I have two network interfaces wlan0 and usb0 on a RaspberryPi running Ubuntu. All of them are connected to the Internet.

I'm writing a python script to run a web server on wlan0. When a request is sent to my pi, I will send another request to usb0, the response data will be send back to where the original request come from.

Image

When I'm trying to send a test request through wlan0, it does work as expected. But when I try to use usb0 instead, it does not work

ifconfig output:

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

Routing Table:

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

Sorry if I'm asking a stupid question, I'm a completely noob at this networking stuff...

1 Answer 1

0

So somehow I figured it out. You need to run curl as root or add CAP_NET_RAW capability to the /usr/bin/curl binary in order for it to work.

In my case I only need to run my python script with root privileges, and it's working now.

More details can be found at https://linux.die.net/man/7/capabilities

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .