Skip to content

Instantly share code, notes, and snippets.

@matinrco
Last active April 11, 2020 12:26
Show Gist options
  • Save matinrco/b438b0e3880925baf8cadfd9d1e6b31e to your computer and use it in GitHub Desktop.
Save matinrco/b438b0e3880925baf8cadfd9d1e6b31e to your computer and use it in GitHub Desktop.
Raspberry pi - Huawei HiLink (E8372 LTE usb dongle) to ethernet adapter - tested on raspbian buster
  1. Set static ip address to raspberry pi eth0 (ethernet) in /etc/network/interfaces.d/eth0 :

    auto eth0
    iface eth0 inet static
        address 192.168.1.20/24
  2. Uncomment IP forwarding from /etc/sysctl.conf :

    net.ipv4.ip_forward=1

    save & reboot.

  3. Enable nat with iptables:

    sudo iptables -t nat -A POSTROUTING -j MASQUERADE
  4. Now connect raspberry pi ethernet cable to your computer or switch device then assign ip like this :

    ip : 192.168.1.21/24
    gw : 192.168.1.20
    dns: 1.1.1.1,1.0.0.1

    You can also automate ip address assignment by setting up an dhcp server!

  5. Save iptables config & make it persistent by installing iptables-persistent package.

    sudo apt install iptables-persistent

    during installation process it will ask you by prompting a dialog to save previous iptables config. Answer yes. if you forgot you can run this process again by running :

    sudo dpkg-reconfigure iptables-persistent

    iptables-persistent package will save iptables configs in /etc/iptables/rules.v4 & /etc/iptables/rules.v6 and it will automatic loading of the saved iptables rules on boot time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment