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
2
3
4
5
$ wget https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/install.sh

$ chmod +x install.sh

$ sudo ./install.sh

Tips for options

  • Choose your Sixfab
    • 6 for the Raspberry Pi 3G/4G&LTE Base HAT (The option 2 for 3G, 4G/LTE Base Shield is compatible with 6)
  • 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

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
2
3
4
5
6
7
8
9
network:
ethernets:
eth0:
addresses: [192.168.2.1/24]
gateway4: 192.168.2.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2

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!

More about netplan.

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
2
3
4
5
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=2 ttl=51 time=123.8 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=51 time=82.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=51 time=95.7 ms