migrate openvpn server from windows to linux

  1. apt-get install openvpn
  2. copy all files from openvpn/configs folder to /etc/openvpn
  3.  download and config checkpwd.sh
    •  cd /etc/openvpn/
    • wget http://openvpn.se/files/other/checkpsw.sh
    • nano checkpws.sh # change password file path if needed
      • PASSFILE=”/etc/openvpn/userpwd”
    • chmod +x checkpsw.sh
  4.  modify server.conf (windows version may prefer this file name: server.ovpn), change checkpsw.exe to absolute path of checkpws.sh, also change clients folder to absolute path
    • auth-user-pass-verify /etc/openvpn/checkpsw.sh via-env
    • client-config-dir /etc/openvpn/clients
  5.  config iptables: disallow accessing LAN from VPN, but allow accessing from LAN.
    • iptables -I FORWARD 1 -i tun0 -o eth0 -s 10.8.0.0/24 -d 192.168.249.0/24 -m conntrack –ctstate NEW -j DROP 
    • iptables  -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
    • I also set following lines to avoid config other rules(because this is a raspberry pi behide a router, will expose 1194 port only)
      • iptables -A INPUT -j ACCEPT
        iptables -A FORWARD -j ACCEPT
        iptables -A OUTPUT -j ACCEPT
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s