{"id":1391,"date":"2017-12-25T17:35:37","date_gmt":"2017-12-25T17:35:37","guid":{"rendered":"https:\/\/www.benfreke.org\/?p=1391"},"modified":"2021-11-02T19:30:53","modified_gmt":"2021-11-02T19:30:53","slug":"raspberry-pi-3g-4g-hotspot","status":"publish","type":"post","link":"https:\/\/wordpress.benfreke.org\/2017\/12\/25\/raspberry-pi-3g-4g-hotspot\/","title":{"rendered":"Raspberry Pi into a 3G \/ 4G Hotspot"},"content":{"rendered":"\n

This guide allows you to convert a Raspberry Pi into a 3G or 4G Hotspot, using a 3G or 4G Modem and a WiFi card.<\/p>\n\n\n\n\n\n\n\n

Prerequisites:<\/h3>\n\n\n\n
  1. You must have a 3G or 4G USB Modem (in this example, I am using a ZTE MF112 3G Modem from Three)<\/li>
  2. You must have a wireless adaptor (either build in to the Pi or a compatible external one)<\/li>
  3. You must have imaged the Pi with the latest Raspian build. The version I used is downloadable here.<\/li><\/ol>\n\n\n\n

    Preparing the Raspberry Pi:<\/h3>\n\n\n\n

    Firstly, you need update the Raspberry Pi image.<\/p>\n\n\n\n

    [sourcecode language=\"python\" wraplines=\"false\" collapse=\"false\"]\nyour source code goes here\n[\/sourcecode]\n<\/pre>\n\n\n\n
    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    sudo<\/code> apt-get update<\/code><\/div>\n
    sudo<\/code> apt-get upgrade<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    Then, you need to download and install some packages, as follows:<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    sudo<\/code> apt-get <\/code>install<\/code> usb-modeswitch ppp dnsmasq hostapd<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    This installs usb-modeswitch<\/a> (we’ll see this later) which allows you to configure your 3G Modem to be used as a 3G Modem, ppp<\/a> which is the Point-to-Point Protocol <\/em>daemon to establish internet links over dialup modems, dnsmasq<\/a> which provides a DHCP server for the wireless LAN, and hostapd<\/a> which allows you to create the wireless hotspot.<\/p>\n\n\n\n

    You’ll also need to download UTMS keeper, as follows:<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    mkdir<\/code> umtskeeper<\/code><\/div>\n
    cd<\/code> umtskeeper<\/code><\/div>\n
    sudo<\/code> wget <\/code>\"https:\/\/www.benfreke.org\/wp-content\/uploads\/2017\/12\/umtskeeper.tar.gz\"<\/a><\/code><\/div>\n
    sudo<\/code> tar<\/code> -xzvf umtskeeper.<\/code>tar<\/code>.gz<\/code><\/div>\n
    sudo<\/code> mkdir<\/code> \/opt\/umtskeeper<\/code><\/div>\n
    sudo<\/code> cp<\/code> -r . <\/code>\/opt\/umtskeeper<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    Configuring your 3G Modem:<\/h3>\n\n\n\n

    A lot of 3G \/ 4G Modems come with file systems which contain installers for Windows and OSX. The Raspberry Pi often detects these and registers the modem as a storage device, instead of its true purpose. This is why usb-modeswitch is used, to switch the mode of the USB Device.<\/p>\n\n\n\n

    To do this, we need to find all the USB devices on the Pi.<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    lsusb<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    This will churn out something like this:<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    Bus 001 Device 004: ID 050d:2103 Belkin Components F7D2102 802.11n N300 Micro Wireless Adapter v3000 [Realtek RTL8192CU]<\/code><\/div>\n
    Bus 001 Device 006: ID 19d2:0031 ZTE WCDMA Technologies MSM MF110<\/code>\/MF627\/MF636<\/code><\/div>\n
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512<\/code>\/9514<\/code> Fast Ethernet Adapter<\/code><\/div>\n
    Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. SMC9512<\/code>\/9514<\/code> USB Hub<\/code><\/div>\n
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    My device (ZTE WCDMA Technologies…) is showing up here. To confirm that your device is acting as a modem as not as removable storage, you need to edit the modeswitch config file. For this, you need the DefaultVendor and DefaultProduct parameters, which usually can be found by going a quick Google search for ‘<<Dongle Model Number>> usb_modeswitch’.<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    sudo<\/code> nano <\/code>\/etc\/usb_modeswitch<\/code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    At the bottom of this file, add the following lines:<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    DefaultVendor = 0x<<VendorID>><\/code><\/div>\n
    DefaultProduct = 0x<<ProductID>><\/code><\/div>\n
    MessageEndPoint = <\/code>\"0x01\"<\/code><\/div>\n
    MessageContent = <\/code>\"55534243000000000000000000000011060000000000000000 000000000000\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    Where <<VendorID>> and <<ProductID>> are the information you found online. Sometimes, they are revelaed in the lsusb command, but you must ensure that they are correct (i.e. actually a modem). In my lsusb, the VendorID is 19d2 and the ProductID is 0031 but in my modeswitch config file, I enter 0103 for my ProductID.<\/p>\n\n\n\n

    Connecting to the cellular network:<\/h3>\n\n\n\n

    We installed UMTSkeeper earlier, who’s job it is to automatically connect (and re-connect should the connection drop out) the 3G connection. This uses sakis3g to do that. It’s prudent to check the 3G connection before we script the connection automatically with UMTSkeeper .<\/p>\n\n\n\n

    Firstly, we need to sakis3g and utmskeeper executable.<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    sudo<\/code> chmod<\/code> +x <\/code>\/opt\/umtskeeper\/sakis3g<\/code><\/div>\n
    sudo<\/code> chmod<\/code> +x <\/code>\/opt\/umtskeeper\/umtskeeper<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    Then, we can run sakis3g with the interactive <\/em>flag to test our 3G connection:<\/p>\n\n\n\n

    \n
    \n
    \n
    \n\n\n\n
    \n
    \n
    sudo<\/code> .<\/code>\/sakis3g<\/code> --interactive<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

    This will guide you through the process of connecting to the internet using your 3G Modem.<\/p>\n\n\n\n

    1. Choose ‘Connect with 3G’<\/li>
    2. In the ‘Select Modem Type’, choose ‘1. USB device’<\/li>
    3. Under ‘Please select USB modem’, select your USB Modem (in my case, it’s ZTE WCDMA Technologies MSM).<\/li>
    4. Under ‘Please select an APN’, either choose your carrier’s APN or select ‘Custom APN’ (in my case, it’s offered ‘Mobile Device (three.co.uk)’ which I know is the correct APN’<\/li>
    5. You should receive a notification confirming the device is connected. In my case, it says ‘MF112 connected to 3’.<\/li>
    6. Under ‘Please select an action’, click ‘Exit’ and you will return to the command line.<\/li><\/ol>\n\n\n\n

      To make sure the device is actually connected:<\/p>\n\n\n\n

      \n
      \n
      \n
      \n\n\n\n
      \n
      \n
      pi@raspberrypi:<\/code>\/opt\/umtskeeper<\/code> $ <\/code>ifconfig<\/code><\/div>\n
      ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500<\/code><\/div>\n
              <\/code>inet 10.120.8.29  netmask 255.255.255.255  destination 10.64.64.64<\/code><\/div>\n
              <\/code>ppp  txqueuelen 3  (Point-to-Point Protocol)<\/code><\/div>\n
              <\/code>RX packets 6  bytes 102 (102.0 B)<\/code><\/div>\n
              <\/code>RX errors 0  dropped 0  overruns 0  frame 0<\/code><\/div>\n
              <\/code>TX packets 7  bytes 141 (141.0 B)<\/code><\/div>\n
              <\/code>TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

      Now we’ve proven the connection, we need to automate it. Let’s disconnect from 3G to not waste that data! Hop back in to the sakis3g interactive session and select ‘Disconnect’.<\/p>\n\n\n\n

      In doing this, we’ve established some settings we’ll need to use with UTMSkeeper. We’ve established that:<\/p>\n\n\n\n

      • The APN is three.co.uk<\/em><\/li>
      • The APN does not require a username or password
        <\/em><\/li>
      • The USB Modem is running correctly<\/li><\/ul>\n\n\n\n

        We can run that connection in one command:<\/p>\n\n\n\n

        \n
        \n
        \n
        \n\n\n\n
        \n
        \n
        sudo<\/code> \/opt\/umtskeeper\/sakis3g<\/code> connect --nostorage --pppd APN=<\/code>\"three.co.uk\"<\/code> APN_USER=<\/code>\"0\"<\/code> APN_PASS=<\/code>\"0\"<\/code> USBINTERFACE=<\/code>\"19d2:0031\"<\/code> USBDRIVER=<\/code>\"option\"<\/code> OTHER=<\/code>\"USBMODEM\"<\/code> USBMODEM=<\/code>\"19d2:0031\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

        Here are the components of that command:<\/p>\n\n\n\n

        • APN – the APNof your carrier<\/li>
        • APN_USER – the APN user of your carrier. If you didn’t need one, enter 0<\/li>
        • APN_PASS – the APN password of your carrier. If you didn’t need one, enter 0<\/li>
        • USBINTERFACE – the ID of your USB Modem, found above when we did lsusb<\/em>.<\/li>
        • USBMODEM – also the ID of your USB Modem<\/li><\/ul>\n\n\n\n

          So running that command connects the device up to the internet again. We can confirm this by performing ifconfig<\/em> again. Now we’ve confirmed the parameters we need for UMTSkeeper. To disconnect, just run sakis3g with disconnect.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> \/opt\/umtskeeper\/sakis3g<\/code> disconnect<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          The UMTSkeeper command is similar, as follows:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          \/opt\/umtskeeper\/umtskeeper<\/code> --sakisoperators <\/code>\"USBINTERFACE='19d2:0031' OTHER='USBMODEM' USBMODEM='19d2:0031' USBDRIVER='option' OTHER='USBMODEM' APN='CUSTOM_APN' CUSTOM_APN='three.co.uk' APN_USER='0' APN_PASS='0'\"<\/code> --sakisswitches <\/code>\"--sudo --console\"<\/code> --devicename <\/code>'MF112'<\/code> --log --silent --monthstart 8 --nat <\/code>'no'<\/code> &<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Ensure that the options you set up using the sakis3g executable are placed in the correct bits in the UMTSkeeper executable..<\/p>\n\n\n\n

          Clearly, we want this to start when the pi boots, so we need to put it into \/etc\/rc.local which will run that command on start.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/rc<\/code>.<\/code>local<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          I added the command straight above the commands to print the IP Address of the Pi when it boots.<\/p>\n\n\n\n

          Creating a WiFi Hotspot:<\/h3>\n\n\n\n

          As we haven’t configured anything, we need to stop dnsmasq <\/em>and hostapd<\/em>:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> systemctl stop dnsmasq<\/code><\/div>\n
          sudo<\/code> systemctl stop hostapd<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          We then need to configure a static IP address on to the Wireless interface. Hop in to:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/dhcpcd<\/code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          At the bottom (but above any other interface <\/em>configuration options), enter the following information:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          interface wlan0<\/code><\/div>\n
          static ip_address=<<IP_Address>><\/code>\/24<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          The name of the interface can be found by running the ifconfig <\/em>command. Change <<IP_Address>> with your intended IP Address.<\/p>\n\n\n\n

          To configure the DHCP Server, we need to edit options in the DHCP config file:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> mv<\/code> \/etc\/dnsmasq<\/code>.conf <\/code>\/etc\/dnsmasq<\/code>.conf.orig<\/code><\/div>\n
          sudo<\/code> nano <\/code>\/etc\/dnsmasq<\/code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Then, enter the following information:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          interface=wlan0      <\/code># Use the require wireless interface - usually wlan0<\/code><\/div>\n
            <\/code>dhcp-range=<<Subnet_Start>>,<<Subnet_Stop>>,255.255.255.0,24h<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Change <<Subnet_Start>> and <<Subnet_Stop>> with your intended IP Addresses.<\/p>\n\n\n\n

          Now we’re ready to configure the access point:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/hostapd\/hostapd<\/code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Enter the following information:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          interface=wlan0<\/code><\/div>\n
          driver=nl80211<\/code><\/div>\n
          ssid=<<Your_Network_Name>><\/code><\/div>\n
          hw_mode=g<\/code><\/div>\n
          channel=7<\/code><\/div>\n
          wmm_enabled=0<\/code><\/div>\n
          macaddr_acl=0<\/code><\/div>\n
          auth_algs=1<\/code><\/div>\n
          ignore_broadcast_ssid=0<\/code><\/div>\n
          wpa=2<\/code><\/div>\n
          wpa_passphrase=<<Your_Network_Passcode>><\/code><\/div>\n
          wpa_key_mgmt=WPA-PSK<\/code><\/div>\n
          wpa_pairwise=TKIP<\/code><\/div>\n
          rsn_pairwise=CCMP<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Replace <<Your_Network_Name>> and <<Your_Network_Passcode>> with your own values.<\/p>\n\n\n\n

          We need to tell the system where to find the configuration file:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/default\/hostapd<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Find the line with #DAEMON_CONF <\/em>and replace it with the following:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          DAEMON_CONF=<\/code>\"\/etc\/hostapd\/hostapd.conf\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Finally, reboot the Pi.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> reboot<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          NATting the Connection:<\/h3>\n\n\n\n

          Firstly, we need to enable IP Forwarding:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/sysctl<\/code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Remove the #<\/em> before the line that reads #net.ipv4.ip_forward=1 <\/em>and save the file.<\/p>\n\n\n\n

          Then, run the following commands:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE<\/code><\/div>\n
          sudo<\/code> iptables -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT<\/code><\/div>\n
          sudo<\/code> iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT<\/code><\/div>\n
          sudo<\/code> sh -c <\/code>\"iptables-save > \/etc\/iptables.ipv4.nat\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          To have the IP Tables load each time the Pi starts:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/rc<\/code>.<\/code>local<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          And add the following line above the UMTSkeeper command we added earlier.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          iptables-restore < <\/code>\/etc\/iptables<\/code>.ipv4.nat<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Finally, reboot the Pi.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> reboot<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Congratulations! When the Pi boots back up, it should be a fully functioning 3G WiFi hotspot.<\/p>\n\n\n\n

          Firewalling<\/h3>\n\n\n\n

          Since your Pi will be out on the open internet, it’s probably a good idea to have some sort of a firewall going! We’ll use UFW.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> apt-get <\/code>install<\/code> ufw<\/code><\/div>\n
          sudo<\/code> ufw default deny incoming<\/code><\/div>\n
          sudo<\/code> ufw default allow outgoing<\/code><\/div>\n
          sudo<\/code> ufw allow from <<Your_IP_Subnet>><\/code>\/24<\/code> to any port 80<\/code><\/div>\n
          sudo<\/code> ufw allow from <<Your_IP_Subnet>><\/code>\/24<\/code> to any port 443<\/code><\/div>\n
          sudo<\/code> ufw allow from <<Your_IP_Subnet>><\/code>\/24<\/code> to any port 53<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          If you’re SSHing in to your pie, you’ll want to add:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> apt-get <\/code>install<\/code> ufw<\/code><\/div>\n
          sudo<\/code> ufw default deny incoming<\/code><\/div>\n
          sudo<\/code> ufw default allow outgoing<\/code><\/div>\n
          sudo<\/code> ufw allow <\/code>ssh<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          You’ll also need to tell UFW to allow IP Forwarding, as follows:<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> nano <\/code>\/etc\/default\/ufw<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n

          Change ‘DEFAULT_FORWARD_POLICY’ from ‘DROP’ to ‘ACCEPT’. Then, run the final command.<\/p>\n\n\n\n

          \n
          \n
          \n
          \n\n\n\n
          \n
          \n
          sudo<\/code> ufw <\/code>enable<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
          \n

          Sources:<\/p>\n

            \n
          1. https:\/\/forums.opensuse.org\/showthread.php\/484430-How-do-I-get-openvpn-to-automatically-restart-after-a-network-interruption<\/a><\/li>\n
          2. https:\/\/stephen.rees-carter.net\/thought\/how-to-enable-ip-forwarding-with-ufw<\/a><\/li>\n
          3. http:\/\/www.instructables.com\/id\/Raspberry-Pi-as-a-3g-Huawei-E303-wireless-Edima\/<\/a><\/li>\n
          4. http:\/\/genietvanhetleven.blogspot.co.uk\/2012\/07\/sakis3g-command-line.html<\/a><\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

            This guide allows you to convert a Raspberry Pi into a 3G or 4G Hotspot, using a 3G or 4G Modem and a WiFi card.<\/p>\n","protected":false},"author":1,"featured_media":1392,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/posts\/1391"}],"collection":[{"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/comments?post=1391"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/posts\/1391\/revisions"}],"predecessor-version":[{"id":1829,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/posts\/1391\/revisions\/1829"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/media\/1392"}],"wp:attachment":[{"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/media?parent=1391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/categories?post=1391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.benfreke.org\/wp-json\/wp\/v2\/tags?post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}