<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=FIREWALL%3A_iptables%3A_Create_NAT_%28en%29</id>
	<title>FIREWALL: iptables: Create NAT (en) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=FIREWALL%3A_iptables%3A_Create_NAT_%28en%29"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=FIREWALL:_iptables:_Create_NAT_(en)&amp;action=history"/>
	<updated>2026-04-21T04:39:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=FIREWALL:_iptables:_Create_NAT_(en)&amp;diff=71803&amp;oldid=prev</id>
		<title>Unknown user: Created page with &quot;Make sure the 3G connection is well established first. One of the easiest is Using Vodafone Mobile Connect Card Driver For Linux.  Afterwards, we can run this Internet Con...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=FIREWALL:_iptables:_Create_NAT_(en)&amp;diff=71803&amp;oldid=prev"/>
		<updated>2025-01-07T01:02:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Make sure the 3G connection is well established first. One of the easiest is &lt;a href=&quot;/wiki/index.php?title=Using_Vodafone_Mobile_Connect_Card_Driver_For_Linux&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Using Vodafone Mobile Connect Card Driver For Linux (page does not exist)&quot;&gt;Using Vodafone Mobile Connect Card Driver For Linux&lt;/a&gt;.  Afterwards, we can run this Internet Con...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Make sure the 3G connection is well established first. One of the easiest is [[Using Vodafone Mobile Connect Card Driver For Linux]].&lt;br /&gt;
&lt;br /&gt;
Afterwards, we can run this Internet Connection Sharing script. See below for script details.&lt;br /&gt;
To run the script:&lt;br /&gt;
&lt;br /&gt;
 # ./script.sh start&lt;br /&gt;
&lt;br /&gt;
To turn it off:&lt;br /&gt;
&lt;br /&gt;
 # ./script.sh stop&lt;br /&gt;
&lt;br /&gt;
To have script.sh automatically on when the computer boots, you can write the script in the folder (for example) /root. Add to the file /etc/rc.local the command:&lt;br /&gt;
&lt;br /&gt;
 /root/script.sh start&lt;br /&gt;
&lt;br /&gt;
The content of script.sh is as shown below. There are several parameters to pay attention to:&lt;br /&gt;
&lt;br /&gt;
* UPLINK&lt;br /&gt;
* NAT&lt;br /&gt;
* INTERFACES&lt;br /&gt;
&lt;br /&gt;
Make sure you correctly fill in all three.&lt;br /&gt;
&lt;br /&gt;
==Internet Connection Sharing Script==&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # From: AHK &amp;lt;akuhon@kompas.com&amp;gt;&lt;br /&gt;
 # To: linux-admin@linux.or.id&lt;br /&gt;
 # Save this file and activate through # file_name start&lt;br /&gt;
 # and de-activate through # file_name stop&lt;br /&gt;
&lt;br /&gt;
 # This firewall script can be used for a workstation, laptop, router,&lt;br /&gt;
 # or server that are not running network service (such as web server, ftp&lt;br /&gt;
 # server, etc.)&lt;br /&gt;
&lt;br /&gt;
 # Change the parameter UPLINK with Interface device to the Internet.&lt;br /&gt;
 # In our case, a WLAN router with NIC wlan0 connected to the Internet&lt;br /&gt;
 # and LAN connection with eth0.&lt;br /&gt;
 # If you use a dial-up modem, you might use ppp0 as your UPLINK.&lt;br /&gt;
&lt;br /&gt;
 UPLINK=&amp;quot;ppp0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # If you run the gateway as a router and forward IP packets between eth devices,&lt;br /&gt;
 # please fill &amp;#039;yes&amp;#039;, if not, please fill &amp;#039;no&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
 ROUTER=&amp;quot;yes&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Please change 192.168.1.100 to your static IP address of the UPLINK device.&lt;br /&gt;
 # For those who use dial-up or dynamic IP, please enter &amp;#039;dynamic&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
 # NAT=&amp;quot;192.168.1.100&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 NAT=&amp;quot;dynamic&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Please list all network interfaces including eth devices&lt;br /&gt;
 # as well as dial-up interface such as ppp0.&lt;br /&gt;
&lt;br /&gt;
 INTERFACES=&amp;quot;lo eth0 eth1 eth2 ppp0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 if [ &amp;quot;$1&amp;quot; = &amp;quot;start&amp;quot; ]&lt;br /&gt;
 then&lt;br /&gt;
   echo &amp;quot;Activate Firewall ..... &amp;quot;&lt;br /&gt;
   /sbin/iptables -F&lt;br /&gt;
   /sbin/iptables -P INPUT DROP&lt;br /&gt;
   /sbin/iptables -A INPUT -i ! ${UPLINK} -j ACCEPT&lt;br /&gt;
   /sbin/iptables -A INPUT -i ${UPLINK} -p tcp -s 0/0 --dport 25 -j ACCEPT&lt;br /&gt;
   /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
   /sbin/iptables -A INPUT -p tcp -i ${UPLINK} -j REJECT --reject-with tcp-reset&lt;br /&gt;
   /sbin/iptables -A INPUT -p udp -i ${UPLINK} -j REJECT --reject-with icmp-port-unreachable&lt;br /&gt;
&lt;br /&gt;
   # Turn off packet spoofing on all interfaces&lt;br /&gt;
   for x in ${INTERFACES}&lt;br /&gt;
   do&lt;br /&gt;
     echo 1 &amp;gt; /proc/sys/net/ipv4/conf/${x}/rp_filter&lt;br /&gt;
   done &lt;br /&gt;
&lt;br /&gt;
   if [ &amp;quot;$ROUTER&amp;quot; = &amp;quot;yes&amp;quot; ]&lt;br /&gt;
   then&lt;br /&gt;
     # Activate IP forwarding at router&lt;br /&gt;
     echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
     if [ &amp;quot;$NAT&amp;quot; = &amp;quot;dynamic&amp;quot; ]&lt;br /&gt;
     then&lt;br /&gt;
       # Dynamic IP address, activate Masquerading&lt;br /&gt;
       echo &amp;quot;Activate Masquerading (Dynamic IP) ....&amp;quot;&lt;br /&gt;
       /sbin/iptables -t nat -A POSTROUTING -o ${UPLINK} -j MASQUERADE&lt;br /&gt;
     elif [ &amp;quot;$NAT&amp;quot; != &amp;quot;&amp;quot; ]&lt;br /&gt;
     then&lt;br /&gt;
       # Static IP address, use source NAT&lt;br /&gt;
       echo &amp;quot;Activate SNAT (Static IP) ....&amp;quot;&lt;br /&gt;
       /sbin/iptables -t nat -A POSTROUTING -o ${UPLINK} -j SNAT --to ${NAT}&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 elif [ &amp;quot;$1&amp;quot; = &amp;quot;stop&amp;quot; ]&lt;br /&gt;
 then&lt;br /&gt;
   echo &amp;quot;Deactivate Firewall ...&amp;quot;&lt;br /&gt;
   /sbin/iptables -F INPUT&lt;br /&gt;
   /sbin/iptables -P INPUT ACCEPT&lt;br /&gt;
   /sbin/iptables -F FORWARD&lt;br /&gt;
   /sbin/iptables -P FORWARD ACCEPT&lt;br /&gt;
   /sbin/iptables -F OUTPUT&lt;br /&gt;
   /sbin/iptables -P OUTPUT ACCEPT&lt;br /&gt;
   # Turn off NAT or MASQUERADING&lt;br /&gt;
   /sbin/iptables -t nat -F POSTROUTING&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
==Interesting Links==&lt;br /&gt;
&lt;br /&gt;
* [[Wireless Internet]]&lt;/div&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
</feed>