-
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
-
Uncomment IP forwarding from
/etc/sysctl.conf
:net.ipv4.ip_forward=1
save & reboot.
-
Enable nat with iptables:
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
-
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!
-
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.
Last active
April 11, 2020 12:26
-
-
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment