Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tips:vpn:openvpn [2015/07/24 12:13] – created scipio | tips:vpn:openvpn [2018/06/14 17:54] (current) – [Linux client] scipio | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| source vars | source vars | ||
| ./clean-all | ./clean-all | ||
| + | ./build-dh | ||
| ./pkitool --initca | ./pkitool --initca | ||
| </ | </ | ||
| Line 22: | Line 23: | ||
| < | < | ||
| NAME=legnago-gw | NAME=legnago-gw | ||
| - | ./pkitool --pass --server $NAME | + | ./pkitool --pass --server $NAME # create passphrase here |
| - | openssl rsa -in keys/ | + | openssl rsa -in keys/ |
| + | chmod 600 keys/ | ||
| </ | </ | ||
| Line 44: | Line 46: | ||
| </ | </ | ||
| + | < | ||
| + | <code bash> | ||
| + | openssl genrsa -des3 -out ca.key 4096 | ||
| + | |||
| + | # specify dns name of mikrotik server in common name | ||
| + | openssl req -new -x509 -days 3650 -key ca.key -out ca.crt | ||
| + | |||
| + | # now import in mikrotik ca.crt and after ca.key | ||
| + | </ | ||
| + | |||
| + | ip pool | ||
| + | < | ||
| + | /ip pool add name=ovpn-pool ranges=10.15.32.34-10.15.32.38 | ||
| + | </ | ||
| + | |||
| + | profile and vpn user | ||
| + | < | ||
| + | /ppp profile | ||
| + | add change-tcp-mss=default comment="" | ||
| + | name=" | ||
| + | use-compression=default use-encryption=required use-vj-compression=default | ||
| + | </ | ||
| + | |||
| + | define vpn user | ||
| + | < | ||
| + | /ppp secret | ||
| + | add caller-id="" | ||
| + | limit-bytes-out=0 name=" | ||
| + | routes="" | ||
| + | </ | ||
| + | |||
| + | openvpn instance | ||
| + | < | ||
| + | /interface ovpn-server server | ||
| + | set auth=sha1, | ||
| + | cipher=blowfish128, | ||
| + | enabled=yes keepalive-timeout=disabled max-mtu=1500 mode=ip netmask=29 \ | ||
| + | port=1194 require-client-certificate=no | ||
| + | </ | ||
| + | |||
| + | ===== Linux client ===== | ||
| + | |||
| + | < | ||
| + | apt-get install openvpn | ||
| + | </ | ||
| + | |||
| + | / | ||
| + | < | ||
| + | dev tun | ||
| + | proto tcp-client | ||
| + | |||
| + | remote legnago.csgalileo.org 1194 | ||
| + | |||
| + | ca / | ||
| + | cert / | ||
| + | key / | ||
| + | |||
| + | tls-client | ||
| + | port 1194 | ||
| + | |||
| + | user nobody | ||
| + | group nogroup | ||
| + | |||
| + | #comp-lzo # Do not use compression. It doesn' | ||
| + | |||
| + | # More reliable detection when a system loses its connection. | ||
| + | ping 15 | ||
| + | ping-restart 45 | ||
| + | ping-timer-rem | ||
| + | persist-tun | ||
| + | persist-key | ||
| + | |||
| + | # Silence | ||
| + | # alarm on WiFi networks. | ||
| + | # the replay protection code without the verbosity associated with | ||
| + | # warnings about duplicate packets. | ||
| + | mute-replay-warnings | ||
| + | |||
| + | # Verbosity level. | ||
| + | # 0 = quiet, 1 = mostly quiet, 3 = medium output, 9 = verbose | ||
| + | verb 3 | ||
| + | |||
| + | cipher AES-256-CBC | ||
| + | auth SHA1 | ||
| + | pull | ||
| + | |||
| + | auth-user-pass auth.cfg | ||
| + | script-security 2 | ||
| + | up / | ||
| + | </ | ||
| + | |||
| + | / | ||
| + | < | ||
| + | #!/bin/sh | ||
| + | |||
| + | ip route add 10.90.0.0/ | ||
| + | </ | ||
| + | |||
| + | / | ||
| + | < | ||
| + | username | ||
| + | password | ||
| + | </ | ||
| + | |||
| + | Start service with systemd | ||
| + | < | ||
| + | systemctl start openvpn@client1 | ||
| + | systemctl enable openvpn@client1 | ||
| + | </ | ||
| + | |||
| + | ===== Linux server ===== | ||
| + | |||
| + | <file txt / | ||
| + | proto tcp | ||
| + | dev tun | ||
| + | |||
| + | ca / | ||
| + | cert / | ||
| + | key / | ||
| + | dh / | ||
| + | |||
| + | server 10.4.0.0 255.255.255.0 | ||
| + | ifconfig-pool-persist ipp.txt | ||
| + | keepalive 10 120 | ||
| + | cipher BF-CBC | ||
| + | max-clients 100 | ||
| + | client-config-dir ccd | ||
| + | |||
| + | # It's a good idea to reduce the OpenVPN | ||
| + | # daemon' | ||
| + | # | ||
| + | # You can uncomment this out on | ||
| + | # non-Windows systems. | ||
| + | user nobody | ||
| + | group nogroup | ||
| + | |||
| + | persist-key | ||
| + | persist-tun | ||
| + | |||
| + | # Output a short status file showing | ||
| + | # current connections, | ||
| + | # and rewritten every minute. | ||
| + | #status / | ||
| + | log / | ||
| + | |||
| + | |||
| + | # 0 is silent, except for fatal errors | ||
| + | # 4 is reasonable for general usage | ||
| + | # 5 and 6 can help to debug connection problems | ||
| + | # 9 is extremely verbose | ||
| + | #log | ||
| + | # | ||
| + | verb 0 | ||
| + | |||
| + | # Silence repeating messages. | ||
| + | # sequential messages of the same message | ||
| + | # category will be output to the log. | ||
| + | mute 20 | ||
| + | |||
| + | #fragment 1300 | ||
| + | mssfix 1300 | ||
| + | #link-mtu 1503 | ||
| + | #tun-mtu 1460 | ||
| + | |||
| + | |||
| + | # | ||
| + | script-security 2 | ||
| + | push " | ||
| + | |||
| + | management localhost 7505 | ||
| + | |||
| + | client-to-client | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Mikrotik client ===== | ||
| + | |||
| + | Import certificates | ||
| + | < | ||
| + | import file-name=ca.crt | ||
| + | import file-name=galileo.crt | ||
| + | import file-name=galileo.pem | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== LXD ===== | ||
| + | |||
| + | To enable tun inside container | ||
| + | < | ||
| + | lxc config device add < | ||
| + | </ | ||