Changes

Jump to navigation Jump to search
425 bytes added ,  12:02, 30 October 2018
Line 31: Line 31:     
= 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 60: Line 60:  
add_nat ${Mapper}
 
add_nat ${Mapper}
 
sudo iptables -t nat --line-numbers -L -n -v<source>
 
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>

Navigation menu