Setup 4G USB modem on RpiB+ connect to router

Hi folks,

I need some help rather urgently and hope someone may be able to respond asap.

I have a functioning USB 4G dongle on my Rpi (3B+)

This Rpi is connected via ethernet to a router (Netgear DGN2200v4) and through to two more Rpis

Currently, when the USB dongle is connected, I can access the Internet but not the other machines via the router, due I suspect to network conflicts.

The USB dongle gets a DHCP IP in the range 192.168.8.xx
The router is also issuing DHCP in the range 192.68.0.xx

From Googling around I guess I need to set up DHCP on the master Rpi and dumb the router down to act as a hub.

Hereā€™s a tutorial which is very close to what I need to achieve. I just donā€™t have the time to make a mess and sort it out.

4g_router

I have installed Teamviewer on the Rpi and, if someone has the skills and time to configure this for me I will enable remote access.

I am also happy to pay for the time it takes.

Cheers
Nigel

Hi Nigel,

Have you tried connecting your Pi router directly to one of the three computers to try to determine where the problem lies? It sounds to me like a configuration in the RPi but it would be good to be certain that itā€™s not the ethernet switch.

Hi Stephen,
Thanks for your interest.

The Master Pi can communicate fine with the other two piā€™s via the router when the 4G USB Dongle isnā€™t active. All the machines are then served DHCP leases from the router, on the same 192.168.0.xx IP range.

Itā€™s only when the USB Dongle is plugged in that the master is ā€˜taken overā€™ by it and assumes an IP address in the 192.168.8.xx range to match that served up by Optus, my mobile data provider.

So I can do all the housekeeping and configuration I need, as long as Iā€™m on location and plugged into the router with my laptop, with no USB modem plugged in. However, Iā€™m about to deploy this device several miles away and need access to configure it remotely. The master Rpi will be powered up on a schedule to enable this.

How have you configured the network interfaces on the ā€œmasterā€ pi? Is IP forwarding turned on?

1 Like

Hi Robin,
Iā€™ve made some progressā€¦ having replaced the Netgear Router with a simple hub which doesnā€™t serve DHCP.

I have installed dnsmasq on the master Rpi and itā€™s serving DHCP to the other RPis (lets call them slaves) connected to the hub.

I can now remotely access the machines and perform essential work however I would like the slaves to be able to see the Internet and currently they canā€™t. Itā€™s a DNS issue that Iā€™m trying to solve now with Google help.

If you are familiar with dnsmasq and DNS please chime in.

Cheers
Nigel

1 Like

I would suggest checking 2 things.

What routes are defined on the slaves? Use the route command to list/show them. This can be configured in the network/interfaces file to add/delete the default gateway when the interface is brought up/down.

What name servers have you defined? Check resolve.conf to see whatā€™s there.

I am pretty rusty on this stuff, but hopefully this will help.

1 Like

Thanks mateā€¦
running route command on a slave I get this result

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 202 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0

and this is the resolv.conf on the same slave

root@piB3_CameraTwo:/home/pi# cat /etc/resolv.conf

Generated by resolvconf

nameserver 192.168.0.1

1 Like

the dhcp server is set as 192.168.0.1 and issuing IPā€™s in the 192.168.0.200+ range

1 Like

To me this says that the slaves can talk to any machine with a 192.168. IP address directly, anything else goes via the 192.168.0.1 machine which I take to be the DHCP / DNSMasq machine. So, is IP forwarding set up on your master machine?

The master machine is also set as the DNS server. So the master must handle the DNS request from the slave or forward the request. I canā€™t remember if DNS requests use UDP as well as TCP. This stuff is probably being set in the DHCP negotiation. But still needs IP forwarding set up on the master if the slaves are to access the internet.

You can use nslookup to see what is or isnā€™t working with name resolution, including setting the name server inside the command.

If you want to access the slaves from the internet, you need to go much further, but get access to internet from the slaves working first.

1 Like

To me this says that the slaves can talk to any machine with a 192.168. IP address directly, anything else goes via the 192.168.0.1 machine which I take to be the DHCP / DNSMasq machine.

Correctā€¦

So, is IP forwarding set up on your master machine?

I havenā€™t done that and itā€™s a new area for me.

I did follow a promising tutorial which showed how to bridge two interfaces to allow internet traffic from slave machines but it was specifically for sharing a wifi access point with other machines on a LAN and it didnā€™t get me all the way.

I can now access the slave machines now, via first sshing into the master then sshing to each slave in turn, However I canā€™t install or update anything on the slaves because they havenā€™t got access to the Net.

Iā€™m pretty happy that Iā€™ve got over the initial problem of accessing the slaves from the master.

I will Google tomorrow for some IP Forwarding material for Raspbian Stretch

Thanks for the pointer
Nigel

1 Like

Hi Nigel, In my experience it is never a good idea to have two DHCP servers on the same subnet - this is why it works fine with simple network switch arrangement but not when going through the daisy chained routers.

Using a 4G dongle is fine for the internet connection, but maybe disable that DHCP and connect it to the router as a ā€˜WANā€™ connection. This might require some reconfiguration for you.

Hope this helps, I am no expert and a bit old school (but that is not always a bad thing) - keep it as simple as possible is my attitude, the more complexity the more likely to have issues.

1 Like

Hi Steve,
I hear you. I hadnā€™t thought of the Wifi Dongle as containing itā€™s own router but I guess it may have to dish out IPs in order for itā€™s host Rpi to get one.

I havenā€™t had time today to look into IP forwarding. Allowing the slaves access to the Net would be nice and convenient, However having solved the major task of remote access I can at least continue in a working fashion. Even if it does mean sshing into the Master then sshing to the slaves from there on in.
Cheers

1 Like

WiFi enabled 4G dongles (commonly referred to as 'Wingles") or non WiFi dongles do have a DHCP server embedded in them because they work as a router for WiFi or USB connected devices.

If you donā€™t use any WiFi component of a Wingle or just a dongle, then you should be able to disable that devices DHCP. I say should, because the setup of two ā€˜routersā€™ can be tricky at times, and require at least some NAT translation.

How are you connecting this device to the Rpi (Master)? via USB - which probably is implemented as a USB ethernet port. You can likely hard code that port to a suitable static IP address/subnet in the range provided by the other router (or get an address from the router DHCP although you might be better connecting the Rpi (Master) to the WAN port on the other router. The other router will like include NAT and other capabilities including IP forwarding and the like, which could be useful to you and also manage some of the remote access needs

I use a Wingle as the second WAN in a dual WAN configuration on my NBN connection via a separate ASUS router. this allows me some peace of mind when there the NBN broadband service slows or fails. I also have another Telstra router/gateway inside my local network (handling VoIP), plus two other APā€™s which use the main router for IP addressing and LAN gateway services. it works well, with plenty of bandwidth shared around many devices. Touch wood, reliability is great with no LAN outages in nearly 2 years - just manual router firmware updates.

The above arrangement is fairly similar to what you are trying to do, I think. As part of some development work I am doing with a Pycom Gpy - I have also tested the network using the GPy LTE connection as the main WAN - no issues at all other than the reduced bandwidth of the 4G service

1 Like

Hi,
The 4G dongle I am using on this rig is a Huawei E3372

https://consumer.huawei.com/au/mobile-broadband/e3372/specs/

Its not wifi enabled as far as I know.

It comes up in the Rpi as eth1

Current config of the Rpi has it acting as DCHP server using DNSMASQ, dishing out in the range 192.168.0.200 - 192.168.0.300

I donā€™t know how to access the router settings on the dongle. If you have any suggestions, other than Google, Iā€™d appreciate some pointers.

Sounds like youā€™re much more comfortable in networking than I. I think of it as the dark art of IT.

Thanks again for your interest. Itā€™s nice not to feel alone in a world of not quite appropriate, often outdated and frequetnly confusing and incomplete tutorials, especially with networking, where one wrong detail can leave one locked out of access. Iā€™ve had to hard reboot my slaves several times now, for lack of connectivity. I wince every time I pill the power, hoping the SD card doesnā€™t decide to write something at the same time.
Nigel

1 Like

Hi Nigel, The E3372 is a single device 4G dongle (note there are several variants of the device with a couple of those specific to Oz). So it connects to a single device (i.e. PC or modem) by USB and has an inbuilt DHCP server, to provide the connected device with an IP address. It sounds like you havenā€™t changed the device settings at all so the USB Dongle will probably have an IP of 192.168.8.1. If you have a PC on the same network/subnet (or plug the dongle into your laptop), type that address into the search bar of your browser- it should connect and bring up the home page, Look on there until you find the Login option and click on that. the username and password will be defaults (admin/password or admin/admin etc.) - if the IP address is different or any of that doesnā€™t work try pressing the reset button on the device as the USB modem may have been reconfigured. You might want to search for a manual too :-).

Once logged in there will be a menu bar where you can select Settings. When that screen comes up, the menu on the left side (i think) will show a an option for LAN - have a hunt around there for the DHCP settingsā€¦ you can set the device IP, DHCP range or enable/disable DHCP. Depending on whether you want to keep another router on your LAN, Iā€™d disable the USB DHCP but there will be setting required to get it working properly. Donā€™t forget to Apply/Save any changes you make and remember that if you change the device IP or DHCP, you will need to log in againā€¦ Good luck - itā€™s worth the effort to get it figured out. :slight_smile:

Those USB modems are from a few years back - Iā€™m pretty sure I have one in my drawer somewhere so I will find it and plug it in and try to help you further.

Newer models (including WiFi wingles) are not expensive even when new from a telco, Officeworks, Australia Post and hardly normal all stock them. if you buy a prepaid one, you can use a postpaid SIM (Telstra/Optus) in it - I have several of the newer ones, the builtin WiFi is handy for wireless connectivity to the device and attached network.

1 Like

Nigel, that DHCP range you quoted is incorrect - max is 192.168.0.254.

1 Like

Thanks again for your continued support and information,
I will get into the settings on my dongle today.
I also have a wireless version, which I could swap in and might be just as useful in the short term because, although I now have remote access, I am not yet in a position to leave the master pi turned on all the time.
The rig is solar powered (with battery back up) and my attempts to schedule daily waking times for it arenā€™t yet working.
I am working on an Arduino solution for this and will implement it asap.
Cheers
Nigel
PS. of course, 255 is the max range for each of the four IP rangesā€¦ I will change that today.

1 Like

You are correct in your assumption that the IP address of the Huawei is 192.168.8.1

Iā€™m just wondering, if I change that to a fixed IP, in the same range (subnet?) ie. 192.168.0.xx that dnsmasq on the Rpi is issuing to the slaves attached to the hub, will the slaves get access to it and, by extension, the Net?
It seems too good to be true, so it probably isnā€™t.
Iā€™ll try it after breakfast.

1 Like

Hi Nigel, changing the dongles IP to a static one, in the same range as the router is worth a tryā€¦ a few variable in that but would be a neat solution. Just ensure that IP you set is outside the DHCP range of the router to avoid conflicts. The other option is to look at port forwarding and NAT. Is the ā€˜eth1ā€™ port on the Rpi just a normal LAN port or a WAN port?

Youā€™ll find the WiFi 4G dongle useful and with more documentation/support available.

Managing power of remote devices is always a challenge! :slight_smile:

1 Like

I just browsed to the USB dongles config page at 192.168.8.0 and couldnā€™t find any settings to change from DHCP to static IP.

Thereā€™s a bunch of settings related to mobile data that I donā€™t recognise but nothing visible in any tabs regarding DHCP. Later today I will try the experiment the other way aroundā€¦ ie change the Rpi Master dnsmasq DHCP assignment range from

192.168.0.xxx
to
192.168.8.xx

That I can do. will report back later

Cheers