fork 0k-charms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
698 B

  1. #!/bin/bash
  2. set -eux
  3. apt-get -y --force-yes install openvpn kal-scripts
  4. mkdir -p /etc/openvpn/clients.d /var/lib/openvpn /var/log/openvpn
  5. ## XXXvlab: why is that ? and if we use tap ?
  6. #mkdir /dev/net
  7. #mknod -m a+rw /dev/net/tun c 10 200
  8. #
  9. # snat.sh
  10. #
  11. # iptables -t nat -A POSTROUTING -s 10.64.0.0/24 -o eth0 -j SNAT --to-source "$(dig +short A "$(hostname -s)")"
  12. #
  13. cat <<EOF > /etc/openvpn/snat.sh
  14. #!/bin/bash
  15. ## example call:
  16. ## <exname> tap0 1500 1574 10.64.0.1 255.255.255.0 init
  17. server_ip="$4"
  18. device="$1"
  19. iptables -t nat -A POSTROUTING -s "$(ifnet "$device")" \
  20. -o eth0 -j SNAT --to-source "$(ifip eth0)" 2>&1 | logger -t iptables
  21. EOF
  22. chmod +x /etc/openvpn/snat.sh