Difference between revisions of "Internet Sharing with a Raspberry Pi"

From Double Jump Electric Wiki
Jump to navigation Jump to search
(Created page with "==from Ubuntu== ==References== * [https://www.raspberrypi.org/forums/viewtopic.php?t=10916 Forum Question] * [https://raspberrypi.stackexchange.com/questions/43560/raspberry...")
 
(from Ubuntu)
Line 1: Line 1:
 
==from Ubuntu==
 
==from Ubuntu==
 +
Open a text editor and save the contents below as ''ipmasq.sh''.
  
 +
<source lang="bash">
 +
#Clears if any old iptable rules/ policies are there.
 +
iptables --flush -t nat
 +
 +
# Now we will do Masquerading ie. we are doing NAT.
 +
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
 +
iptables --append FORWARD --in-interface eth0 -j ACCEPT
 +
 +
# Enabling packet forwarding.
 +
echo 1 > /proc/sys/net/ipv4/ip_forward
 +
</source>
 +
 +
From the terminal, make the file executable with:
 +
<source>
 +
chmod +x
 +
</source>
 +
 +
To share the internet connection, run the file with
 +
<source>
 +
sudo ./ipmasq.sh
 +
</source>
  
 
==References==
 
==References==
 
* [https://www.raspberrypi.org/forums/viewtopic.php?t=10916 Forum Question]
 
* [https://www.raspberrypi.org/forums/viewtopic.php?t=10916 Forum Question]
 
* [https://raspberrypi.stackexchange.com/questions/43560/raspberry-pi-3-eth0-wrongfully-named-enx Renaming USB-to-Ethernet Dongle Connection]
 
* [https://raspberrypi.stackexchange.com/questions/43560/raspberry-pi-3-eth0-wrongfully-named-enx Renaming USB-to-Ethernet Dongle Connection]

Revision as of 11:36, 15 May 2020

from Ubuntu

Open a text editor and save the contents below as ipmasq.sh.

#Clears if any old iptable rules/ policies are there.
iptables --flush -t nat

 # Now we will do Masquerading ie. we are doing NAT.
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

 # Enabling packet forwarding.
echo 1 > /proc/sys/net/ipv4/ip_forward

From the terminal, make the file executable with:

chmod +x

To share the internet connection, run the file with

sudo ./ipmasq.sh

References