Turn Raspberry Pi 3B+ with Ubuntu Server 18.04 into Wired 4G Router
Previous
We have used Raspberry Pi as 4G LTE Router before with NOOBS Raspbian system. This time I installed Ubuntu Server 18.04 for the Raspberry Pi.
However, the workflow does not work as expected with the tutorial we did before. I have just fixed the problems and made it work, here is the new tutorial for newer system.
Driver
I assume you have finished the assembly, or you can check out the older tutorial.
Sixfab provides two methods to control the LTE module, PPP and QMI interface.
I used PPP connection here.
1 | $ wget https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/install.sh |
Tips for options
- Choose your Sixfab
6for theRaspberry Pi 3G/4G<E Base HAT(The option2for3G, 4G/LTE Base Shieldis compatible with6)
- APN
- Google the APN for the service provider
- Or insert the SIM Card to a phone and view the APN in settings
- PORT name
- For 3G, 4G/LTE Base Shield && Base HAT it will be
ttyUSB3 - Always
ttyUSB3, no thing to do with physical port
- For 3G, 4G/LTE Base Shield && Base HAT it will be
Troubleshooting
Auto-connect not working
The automate establish connection bash script does not work on Ubuntu Server 18.04 start up. The connection will fail in start up. The solution is to run the script after boot.
I used crontab with @reboot to run the script after the booting instead of run it in start up.
1 | crontab -e |
If it is the first time to use crontab, a question will pop-up and ask for the default editor for editing crontab jobs. Default nano is suggested, just press Enter. And add the following line.
1 | @reboot /usr/src/reconnect.sh |
Ctrl+X, y, Enter to save the setting in nano.
Other problems
You can check out the older tutorial.
Wired Router
I have setup a wired router before, please follow the instructions there to set up the NAT connection and other DNS/DHCP server.
Beware of the patches below
File interfaces deprecated
Ubuntu Server 18.04 uses netplan, so we do not use /etc/network/interfaces, we edit the file /etc/netplan/50-cloud-init.yaml.
1 | $ sudo nano /etc/netplan/50-cloud-init.yaml |
And change the ethernets section:
1 | network: |
Now verify the yaml file.
1 | $ sudo netplan try |
It will ask user to type enter after passing the testing, if user did not press enter, after a timeout of 120 seconds will automatically rewrite the yaml file to default configuration. I guess it is a fail safe mechanism.
Now apply the configuration.
1 | $ sudo netplan apply |
Done!
No wwan0 device
Change wwan0 to ppp0 in the commands in the old tutorial.
NAT does not work
In Ubnutu 18.04, the rc-local seem to be deprecated that iptables-restore will not be executed. Used crontab to replace it.
1 | $ crontab -e |
And add one more line at the bottom
1 | @reboot sudo iptables-restore < /etc/iptables.ipv4.nat |
DONE
Connect laptop to Raspberry Pi
1 | $ ping 8.8.8.8 |