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
651 B

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