Category: Networking
NAT script in iptables Ubuntu
This script allows you to open access to the Internet through iptables. To solve this problem, you need to create a file with the script, and load it when the system boots.
Create file:
nano /home/your_username/nat
Add to it:
#!/bin/bash
echo "1" > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
modprobe iptable_nat
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
where eth1 is the network card to which the Internet is connected.
After saving, assign the rights:
chmod +x /home/your_username/nat
To run the script in the console, run the following command:
./home/your_username/nat
You can also add this file to the startup.
Posted: 2013-10-17
Comments