0

I am using the AT&T Avnet IoT Starter Kit to provide cellular connectivity to my Raspberry Pi 3b+. In order to establish the routing table I added an ip command to the file /lib/dhcpcd/dhcpcd-hooks/40-route the command I added was:

ip route add default via 0.0.0.0 dev enx001122334456

(The enx001122334456 is the name of my ethernet device, like eth1 but with a 'predictable name').

This sets the routing table, after booting up I'll have a routing table like:

Dest            Gateway     Genmask         Flags Metric Iface
default         0.0.0.0     0.0.0.0         U     0      enx001122334456
default         0.0.0.0     0.0.0.0         U     0      enx001122334456
default         10.0.0.1    0.0.0.0         UG    303    wlan0
10.0.0.0        0.0.0.0     255.255.255.0   U     303    wlan0
10.0.0.1        0.0.0.0     255.255.255.240 U     221    enx001122334456
10.47.206.96    0.0.0.0     255.255.255.240 U     221    enx001122334456
...
Down here there are a bunch of docker virtual ethernet interfaces and bridge networks

This does exactly what I want it to do for a while, but then it seems to reset (I think it is a changing of the IP addresses that triggers it) and I no longer have my default route. I am using dhcp, so it makes sense that the ip address is changing, but it doesn't make sense that it would have an adverse effect on the routing table. Instead it becomes:

Dest            Gateway     Genmask         Flags Metric Iface
default         0.0.0.0     0.0.0.0         U     0      enx001122334456
default         10.0.0.1    0.0.0.0         UG    303    wlan0
10.0.0.0        0.0.0.0     255.255.255.0   U     303    wlan0
10.0.0.1        0.0.0.0     255.255.255.240 U     221    enx001122334456
10.47.206.96    0.0.0.0     255.255.255.240 U     221    enx001122334456
...

which, although nearly identical, ping 8.8.8.8 doesn't work. Sometimes, even if I specify the interface with ping -I enx001122334456 8.8.8.8 it won't work.

I'm thoroughly confused. I have no idea how to continue debugging this, I just want it to work. Anyone have any knowledge on what could be causing my routing table to reset. Even if you just give me debugging tools or tricks that would be amazing.

2 Answers2

2

You should allow interface associated with cellular connection to be configured completely via DHCP. Part of the process is also setting up default router. You should have only one default path in the system. (It is possible to have more but that leads to complications you don't need or want). Network on Raspbian can be configured via dhcpcd or classic debian networking subsystem. You can toggle between them by using

#systemctl disable dhcpcd
#systemctl enable networking

or the opposite.

I prefer networking for headless devices. Even if it is bit dumber and slower but at the same time more reliable - if you want to have interface configured even without Ethernet cable plugged in. Dhdpcd will attempt to configure any visible interface so when you switch to Debian's networking subsystem you will have to set up configuration for every interface you want to be configured during system boot. As I said it is my preference mainly due to fact that it will deal with all interfaces before allowing system to continue. It is important if you have services bound to specific interface, etc.

In case od dhcpcd configuration is in /etc/dhcpcd.conf and networking in /etc/network/interfaces.

Dhcpcd is more than just DHCP client. In Raspbian it is used to completely configure networking and even manage Wi-Fi interfaces. You may define specific rules for every interface including static IP configuration. It is great for devices where network settings change frequently or there are many possible configurations.

/etc/network/interfaces:

auto enx001122334456
allow-hotplug enx001122334456
iface enx001122334456 inet dhcp

Should be all you need to properly set up internet access and make it work across reboots.

Make sure that other interfaces are not auto-configured with default router via DHCP and you're good. Check documentation for mechanism of your choice (man interfaces or man dhcpcd.conf). There is plenty of useful information in there.

Have a look at this topic.

1

The default route needs a Gateway where to send packages with a destination the kernel does not know. The Gateway must be a host (router) on the same network the RasPi is direct connected to with an interface. According to your routing table the RasPi is connected to two subnets:

10.0.0.0/24     with addresses from 10.0.0.1     to 10.0.0.254    on interface wlan0
10.47.206.96/28 with addresses from 10.47.206.97 to 10.47.206.110 on interface enx001122334456

The gateway must have one of this ip addresses. I don't know on which subnet your gateway resides. It is up to you to find it out. I guess you have a wired uplink so it could be on 10.47.206.96/28, for example 10.47.206.97. Then you have to set the default route to:

ip route add default via 10.47.206.97 dev enx001122334456

You have more than one default route in your routing table. You should ensure that you have only one.

Ingo
  • 42,961
  • 20
  • 87
  • 207