OTG Ethernet Gadget

Hello,

I want to have my Radxa Zero 3W’s USB 2.0 OTG port as a ethernet gadget and will use a USB cable to connect an iPad with Zero 3W so I can directly ssh into it while ideally my other internet network traffic will be routed through my wlan0 or my enx00e04c683a65 device (A usb 3.0 hub with a ethernet port)

ubuntu@rock-zero3w-ubuntu-rockchip:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: end1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 9a:f7:ff:6d:75:60 brd ff:ff:ff:ff:ff:ff
3: enx00e04c683a65: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:e0:4c:68:3a:65 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.178/24 metric 100 brd 192.168.1.255 scope global dynamic enx00e04c683a65
       valid_lft 84807sec preferred_lft 84807sec
    inet6 fd20:d1de:9ede:3d4e:2e0:4cff:fe68:3a65/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 1797sec preferred_lft 1797sec
    inet6 fe80::2e0:4cff:fe68:3a65/64 scope link 
       valid_lft forever preferred_lft forever
4: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether f6:c3:89:8d:78:7b brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.2/24 brd 192.168.7.255 scope global usb0
       valid_lft forever preferred_lft forever
    inet6 fe80::f4c3:89ff:fe8d:787b/64 scope link 
       valid_lft forever preferred_lft forever
5: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 98:03:cf:c6:e4:14 brd ff:ff:ff:ff:ff:ff
6: tailscale0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet6 fe80::ab8:a4d5:9aae:a953/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever
7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:b6:6f:bf:0b brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

However, I have gone as far as setting up the OTG Ethernet Gadget but if it’s plugged in, there’s no internet. I can still ping to my router and other network devices within my LAN (192.168.1.x) but somehow the usb0 device has automatically created a 192.168.7.0/24 network in which it doesn’t have an internet gateway.

Before OTG is plugged in:

ubuntu@rock-zero3w-ubuntu-rockchip:~$ ip route
default via 192.168.1.1 dev enx00e04c683a65 proto dhcp src 192.168.1.178 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 dev enx00e04c683a65 proto kernel scope link src 192.168.1.178 metric 100 
192.168.1.1 dev enx00e04c683a65 proto dhcp scope link src 192.168.1.178 metric 100 

After OTG is plugged in:

ubuntu@rock-zero3w-ubuntu-rockchip:/sys/kernel/config/usb_gadget$ ip route
default via 192.168.7.1 dev usb0 proto static 
default via 192.168.1.1 dev enx00e04c683a65 proto dhcp src 192.168.1.178 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 dev enx00e04c683a65 proto kernel scope link src 192.168.1.178 metric 100 
192.168.1.1 dev enx00e04c683a65 proto dhcp scope link src 192.168.1.178 metric 100 
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2

Anyone has any success with similar use case? I am using the latest of ubuntu-rockchip

If you want to connect Ethernet to the Radxa zero 3w, it is recommended to do so via the USB3.0 type-c port.

The usb0 192.168.7.0/24 generated by your question above is a usb shared network.