892
edits
Line 21: | Line 21: | ||
case "$1" in | case "$1" in | ||
start) | start) | ||
echo "Starting mesh NAT" | if [ "`iptables -t nat -L|grep MASQUERADE`" = '' ]; then | ||
echo "Starting mesh NAT" | |||
echo 1 > /proc/sys/net/ipv4/ip_forward | |||
iptables -t nat -A POSTROUTING -o $PUBIF -j MASQUERADE | |||
iptables -A FORWARD -i $PUBIF -o $BATIF -m state --state RELATED,ESTABLISHED -j ACCEPT | |||
iptables -A FORWARD -i $PUBIF -o $BATIF -j DROP | |||
else | |||
echo "Mesh NAT already started" | |||
fi | |||
;; | ;; | ||
stop) | stop) | ||
Line 38: | Line 42: | ||
;; | ;; | ||
esac | esac | ||
</pre> | </pre> | ||
Line 47: | Line 52: | ||
if [ `cat /sys/class/net/bat0/operstate` != "up" ]; then | if [ `cat /sys/class/net/bat0/operstate` != "up" ]; then | ||
ifconfig bat0 <relay_mesh_ip> netmask 255.0.0.0 up | |||
fi | fi | ||
Line 53: | Line 58: | ||
if [ `cat /sys/class/net/bat0/operstate` != "up" ]; then | if [ `cat /sys/class/net/bat0/operstate` != "up" ]; then | ||
ifconfig bat0 <exit_mesh_ip> netmask 255.0.0.0 up | |||
/etc/init.d/meshnat start | |||
fi | fi | ||
Where <exit_mesh_ip> is the assigned mesh IP address for your exit node. E.g: 10.42.0.1. | |||
Now NAT should be set up correctly. | Now NAT should be set up correctly. |