wiki:openvpn_installation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wiki:openvpn_installation [2024/04/10 10:48] – add section about systemd service antisa | wiki:openvpn_installation [2025/03/03 16:15] (current) – [See also] add Revoke openvpn certificates antisa | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{tag> | + | {{tag> |
====== Openvpn installation ====== | ====== Openvpn installation ====== | ||
Line 87: | Line 87: | ||
./easyrsa build-ca | ./easyrsa build-ca | ||
- | 3. Create the vpn server' | + | 3. Generate Diffie-Hellman (DH) params. |
+ | ./easyrsa gen-dh | ||
+ | |||
+ | 4. Create the vpn server' | ||
./easyrsa gen-req server nopass | ./easyrsa gen-req server nopass | ||
./easyrsa sign-req server server | ./easyrsa sign-req server server | ||
| | ||
- | 4. Create client signing request and certificate. Change EntityName, '' | + | 5. Create client signing request and certificate. Change EntityName, '' |
./easyrsa gen-req EntityName nopass | ./easyrsa gen-req EntityName nopass | ||
./easyrsa sign-req client EntityName | ./easyrsa sign-req client EntityName | ||
- | 5. Generate Diffie-Hellman (DH) params. | + | |
- | ./easyrsa gen-dh | + | |
| | ||
- | For each new client just repeat step 4. | + | For each new client just repeat |
==== Creating configuration files for server and clients ==== | ==== Creating configuration files for server and clients ==== | ||
Line 127: | Line 129: | ||
You can now try running the openvpn on client and server like mentioned in Simple setup above. | You can now try running the openvpn on client and server like mentioned in Simple setup above. | ||
+ | |||
+ | ==== Redirecting traffic over VPN ==== | ||
+ | === Redirect all traffic === | ||
+ | In server.conf add | ||
+ | |||
+ | push " | ||
+ | |||
+ | |||
+ | In client.conf add: | ||
+ | redirect-gateway def1 | ||
+ | |||
+ | === Redirect only some IPs (aka Split tunnel) === | ||
+ | In server.conf add: | ||
+ | |||
+ | push "route 192.168.10.0 255.255.255.0" | ||
+ | push "route 192.168.20.0 255.255.255.0" | ||
+ | ... | ||
+ | |||
+ | Remove the redirect-gateway lines from conf. | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | [[https:// | ||
+ | </ | ||
+ | |||
+ | ===== Redirect DNS through VPN ===== | ||
+ | First uninstall any other DNS server/ | ||
+ | |||
+ | apt install dnsmasq | ||
+ | |||
+ | Now make the /// | ||
+ | |||
+ | nameserver ::1 | ||
+ | nameserver 127.0.0.1 | ||
+ | options trust-ad | ||
+ | |||
+ | You might need to [[https:// | ||
+ | |||
+ | In /// | ||
+ | |||
+ | listen-address=:: | ||
+ | interface=tun0 | ||
+ | # Google' | ||
+ | server=8.8.8.8 | ||
+ | server=8.8.4.4 | ||
+ | |||
+ | Adapt the listen-address IP to your VPN interface IP and interface as well and uncomment '' | ||
+ | |||
+ | In /// | ||
+ | |||
+ | ... | ||
+ | push " | ||
+ | push " | ||
+ | ... | ||
+ | | ||
+ | <WRAP center round info 60%> | ||
+ | If you run into problems with DNS not going through VPN in Windows installed as a VM in Virtualbox for example, you will need to disable automatic metric on VPN interface and set it to lower then the default Ethernet or wifi. To check open the powershell and type '' | ||
+ | {{ : | ||
+ | </ | ||
+ | |||
+ | ==== Resolve specific domains names to hard-coded IP ==== | ||
+ | Say you need to always resolve example.org to 1.2.3.4 address, you have two options. | ||
+ | |||
+ | 1. Add the resolution to /// | ||
+ | |||
+ | ... | ||
+ | 1.2.3.4 www.example.org example.org | ||
+ | |||
+ | 2. Remove the above from /// | ||
+ | address=/ | ||
+ | |||
+ | Also [[https:// | ||
===== Firewall setup ===== | ===== Firewall setup ===== | ||
Line 138: | Line 211: | ||
#ZONE | #ZONE | ||
net | net | ||
- | vpn tun0 | + | vpn |
</ | </ | ||
Line 200: | Line 273: | ||
====== See also ====== | ====== See also ====== | ||
* [[wiki: | * [[wiki: | ||
+ | * [[wiki: | ||
+ | * [[wiki: | ||
====== References ====== | ====== References ====== | ||
* https:// | * https:// | ||
Line 206: | Line 281: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * [[https:// | ||
wiki/openvpn_installation.1712746099.txt.gz · Last modified: 2024/04/10 10:48 by antisa