Last active
February 14, 2024 07:37
-
-
Save tuna2134/3e505363b0c5f671b95b20f62c1b6732 to your computer and use it in GitHub Desktop.
Router create script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
network: | |
ethernets: | |
eth0: | |
dhcp4: true | |
nameservers: | |
addresses: | |
- 1.1.1.1 | |
eth1: | |
dhcp4: false | |
addresses: | |
- 172.16.70.1/24 | |
version: 2 |
Enable ip forward
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
sysctl -p
IP_Address: 172.16.70.12
Gateway: 172.16.70.1
Enjoy self made router life!
Port forwarding(Sample)
sudo iptables -t nat -A PREROUTING ! -s 192.168.11.0/24 -p tcp -m tcp --dport 30000:32767 -j DNAT --to-destination 172.16.70.12:30000-32767
sudo iptables -t nat -A POSTROUTING -d 192.168.11.0/24 -p tcp -m tcp --dport 30000:32767 -j SNAT --to-source 172.16.42.1:30000-32767
Save iptables setting
iptables-save > /etc/iptables/rules.v4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Masquerade