boot-scripts
boot-scripts copied to clipboard
default gateway not working on usb0
Hi Robert,
Thanks for your work.
I am playing around with the PocketBeagle. I am ssh'ing over usb0, and at the moment I have to type:
sudo ip route add default via 192.168.7.1
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
in order to get internet access on the PocketBeagle.
This is despite my /etc/network/interfaces
file containing:
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
gateway 192.168.7.1
dns-nameservers 8.8.8.8
I can get around the resolv.conf issue by disabling connman:
sudo systemctl disable connman.service
but cannot figure out how to set the default gateway. I am guessing the problem is with autoconfigure_usb0.sh
?
Any suggestions would be greatly appreciated.
Thanks,
Ben
The /etc/network/interfaces
file is parsed by the autoconfigure_usb0.sh
script in /opt/scripts/boot
Looking at that script, although it looks for the gateway value, it doesn't seem to do actually do much with it.
Using the current Debian stretch image, doing a ip route show
after boot reports:
192.168.6.0/30 dev usb1 proto kernel scope link src 192.168.6.2
192.168.7.0/30 dev usb0 proto kernel scope link src 192.168.7.2
If I add a route add default gw 192.168.7.1
as the last command in the final if statement in autoconfigure_usb0.sh
, then after boot, I get:
default via 192.168.7.1 dev usb0
192.168.6.0/30 dev usb1 proto kernel scope link src 192.168.6.2
192.168.7.0/30 dev usb0 proto kernel scope link src 192.168.7.2
and a working network route via my laptop.
For the record, on my linux laptop I'm forwarding from usb to wifi with:
sudo sysctl net.ipv4.ip_forward=1
sudo iptables --table nat --append POSTROUTING --out-interface wlp4s0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface enx985dad314e0d -j ACCEPT
Sadly it's not well documented, but there are some helper scripts here:
https://github.com/RobertCNelson/boot-scripts/tree/master/network
(/opt/scripts/network/)
Regards,