I have been recently struggling to grasp what I am doing wrong here. So I have a micro computer which has two separate network interfaces, usb0 and eth0. usb0 is a radio which I can communicate with from an external device (essentially a modem). eth0 is a camera (which is another computer) which I have plugged into this computer.
Is it possible for an external device connected to usb0 to communicate with a device on eth0? I believe it is, but I am starting to second guess it.
Here are the network interfaces on my linux device:
voxl2:/$ sudo ifconfig
bond0: flags=5123<UP,BROADCAST,MASTER,MULTICAST> mtu 1500
ether da:49:41:51:a8:bf 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
dummy0: flags=195<UP,BROADCAST,RUNNING,NOARP> mtu 1500
inet6 fe80::66b9:adf2:23d1:2eb8 prefixlen 64 scopeid 0x20<link>
ether 5e:da:25:e6:6b:f6 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 9856 (9.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.144.21 netmask 255.255.255.0 broadcast 192.168.144.255
ether 5c:85:7e:3e:94:33 txqueuelen 1000 (Ethernet)
RX packets 1476 bytes 88560 (88.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 37 bytes 10030 (10.0 KB)
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 4 bytes 352 (352.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 352 (352.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.168.100 netmask 255.255.255.0 broadcast 192.168.168.255
inet6 fe80::f27e:51e4:efeb:5592 prefixlen 64 scopeid 0x20<link>
ether 92:46:8f:a0:15:f2 txqueuelen 1000 (Ethernet)
RX packets 81226 bytes 4071362 (4.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 179792 bytes 21740183 (21.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Note that eth0 and usb0 are on different subnets. If I ping the device from this micro computer (ping 192.168.144.52), I get a response.
However, from an external device connected over usb0, pinging the device gives me no response. I am, however, able to ping the ip of the actual interface itself.
ping 192.168.168.100 and ping 192.168.144.21 works.
I first ensured that net.ipv4.ip_forward=1 on /etc/sysctl.conf
Next, I started messing around with the routing table on this linux device.
Here are some variations of routes I tried. I think most were not correct
Variation 1:
voxl2:/$ sudo route add -net 192.168.144.52 netmask 255.255.255.255 gw 192.168.144.1
voxl2:/$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default UserDevice 0.0.0.0 UG 209 0 0 usb0
link-local 0.0.0.0 255.255.0.0 U 208 0 0 eth0
192.168.144.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.144.52 192.168.144.1 255.255.255.255 UGH 0 0 0 eth0
192.168.168.0 0.0.0.0 255.255.255.0 U 209 0 0 usb0
Variation 2:
voxl2:/$ sudo ip route add 192.168.144.0/24 via 192.168.168.100 dev usb0
voxl2:/$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default UserDevice 0.0.0.0 UG 209 0 0 usb0
link-local 0.0.0.0 255.255.0.0 U 208 0 0 eth0
192.168.144.0 192.168.168.100 255.255.255.0 UG 0 0 0 usb0
192.168.168.0 0.0.0.0 255.255.255.0 U 209 0 0 usb0
Variation 3:
voxl2:/$ sudo ip route add 192.168.144.52/32 via 192.168.168.100 dev usb0
voxl2:/$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default UserDevice 0.0.0.0 UG 209 0 0 usb0
link-local 0.0.0.0 255.255.0.0 U 208 0 0 eth0
192.168.144.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.144.52 192.168.168.100 255.255.255.255 UGH 0 0 0 usb0
192.168.168.0 0.0.0.0 255.255.255.0 U 209 0 0 usb0
Variation 4:
voxl2:/$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default UserDevice 0.0.0.0 UG 209 0 0 usb0
link-local 0.0.0.0 255.255.0.0 U 208 0 0 eth0
192.168.144.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.144.52 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
192.168.168.0 0.0.0.0 255.255.255.0 U 209 0 0 usb0
I think I am misunderstanding what the gateway field is doing. Perhaps if I set gateway to 192.168.144.1, destination to 192.168.168.100, and iface to usb0, it might work. I will try that shortly.