From 2d757104935629a6dbffd489becf178c77cd86c2 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 16 Apr 2013 16:32:56 +0200 Subject: [PATCH] new: added ``snat.sh`` script to ``vpn`` charm. --- precise/vpn/hooks/install | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/precise/vpn/hooks/install b/precise/vpn/hooks/install index 3ebb8f4..443bbc9 100755 --- a/precise/vpn/hooks/install +++ b/precise/vpn/hooks/install @@ -3,7 +3,7 @@ set -eux -apt-get -y install openvpn +apt-get -y --force-yes install openvpn kal-scritps mkdir -p /etc/openvpn/clients.d /var/lib/openvpn /var/log/openvpn @@ -12,3 +12,27 @@ mkdir /dev/net mknod -m a+rw /dev/net/tun c 10 200 +# +# snat.sh +# +# iptables -t nat -A POSTROUTING -s 10.64.0.0/24 -o eth0 -j SNAT --to-source "$(dig +short A "$(hostname -s)")" +# + + +cat < /etc/openvpn/snat.sh +#!/bin/bash + +## example call: +## tap0 1500 1574 10.64.0.1 255.255.255.0 init + +server_ip="$4" +device="$1" + +iptables -t nat -A POSTROUTING -s "$(ifnet "$device")" \ + -o eth0 -j SNAT --to-source "$(ifip eth0)" 2>&1 | logger -t iptables + +EOF + +chmod +x /etc/openvpn/snat.sh + +