Changes
Jump to navigation
Jump to search
← Older edit
Debian as router
(edit)
Revision as of 13:50, 31 October 2018
820 bytes added
,
13:50, 31 October 2018
→Start Script
Line 30:
Line 30:
−
= With SystemD
=
=
+
= With SystemD =
−
==
Enable Nat
Script ==
+
==
Start
Script ==
<source lang="bash">#!/bin/bash
<source lang="bash">#!/bin/bash
Ariel=15.17.170.200
Ariel=15.17.170.200
Line 49:
Line 49:
function add_nat {
function add_nat {
−
sudo iptables -t nat -A POSTROUTING -s ${1}/32 -o tun0 -j MASQUERADE
+
sudo iptables -t nat -A POSTROUTING -s ${1}/32
-d 10.0.192.0/18
-o tun0
-j MASQUERADE
+
}
+
+
function add_wlan_nat {
+
sudo iptables -t nat -A POSTROUTING -s ${1}/32 -o wlan0
-j MASQUERADE
}
}
Line 59:
Line 63:
add_nat ${Marito}
add_nat ${Marito}
add_nat ${Mapper}
add_nat ${Mapper}
−
sudo iptables -t nat --line-numbers -L -n -v<source>
+
add_wlan_nat ${Carabanchel}
+
+
sudo iptables -t nat --line-numbers -L -n -v
+
<
/
source>
+
+
== Stop Script ==
+
<source lang="bash">#!/bin/bash
+
sudo sysctl -w net.ipv4.ip_forward=0
+
+
function clear_nat {
+
for i in $( sudo iptables -t nat -L -n -v --line-numbers | grep ^[0-9] | awk '{ print $1 }' )
+
do sudo iptables -t nat -D POSTROUTING 1
+
done
+
}
+
+
function add_nat {
+
sudo iptables -t nat -A POSTROUTING -s ${1}/32 -o tun0 -j MASQUERADE
+
}
+
+
clear_nat
+
sudo iptables -t nat --line-numbers -L -n -v</source>
+
+
== Multiple routes for one source ==
+
* The more specific rule must go first
+
sudo iptables -t nat -A POSTROUTING -s 15.17.170.206 -d 10.0.192.0/18 -o tun0 -j MASQUERADE
+
sudo iptables -t nat -A POSTROUTING -s 15.17.170.206 -o wlan0 -j MASQUERADE
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version