documentation:examples:gre_ipsec_and_openvpn
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
documentation:examples:gre_ipsec_and_openvpn [2022/10/04 15:10] – [VM2: OpenVPN server] olivier | documentation:examples:gre_ipsec_and_openvpn [2023/07/10 12:40] (current) – [Router 4] olivier | ||
---|---|---|---|
Line 1062: | Line 1062: | ||
</ | </ | ||
- | ==== VM2: OpenVPN server | + | ==== Standard userland mode (slow) ==== |
+ | |||
+ | === VM2: OpenVPN server === | ||
Create the openvpn configuration file for server mode as / | Create the openvpn configuration file for server mode as / | ||
Line 1125: | Line 1127: | ||
echo '</ | echo '</ | ||
</ | </ | ||
- | ==== VM4: OpenVPN client | + | |
+ | === VM4: OpenVPN client === | ||
As OpenVPN client, VM4 should get its openvpn configuration file (that embedded certificate and key) from VM2 and put them in / | As OpenVPN client, VM4 should get its openvpn configuration file (that embedded certificate and key) from VM2 and put them in / | ||
Line 1132: | Line 1135: | ||
< | < | ||
mkdir / | mkdir / | ||
- | scp 10.0.23.2:/ | + | scp 10.0.23.2:/ |
</ | </ | ||
- | |||
Enable and start openvpn: | Enable and start openvpn: | ||
Line 1141: | Line 1143: | ||
service openvpn start | service openvpn start | ||
</ | </ | ||
- | ==== Testing | + | |
+ | === Testing === | ||
Pinging VM5 from VM1: | Pinging VM5 from VM1: | ||
Line 1214: | Line 1217: | ||
16: | 16: | ||
16: | 16: | ||
+ | </ | ||
+ | |||
+ | ==== Data Channel Offload (DCO), kernel mode (fast) ==== | ||
+ | |||
+ | Start with a working userland configuration, | ||
+ | * Need to load if_ovpn module on both side | ||
+ | * Need to enable subnet topology on the server side | ||
+ | |||
+ | === VM2: OpenVPN server === | ||
+ | |||
+ | < | ||
+ | service openvpn stop | ||
+ | sysrc kld_list=" | ||
+ | kldload if_ovpn | ||
+ | echo " | ||
+ | service openvpn start | ||
+ | </ | ||
+ | |||
+ | === VM4: OpenVPN client === | ||
+ | |||
+ | < | ||
+ | service openvpn stop | ||
+ | sysrc kld_list=" | ||
+ | kldload if_ovpn | ||
+ | service openvpn start | ||
+ | </ | ||
+ | |||
+ | === Testing === | ||
+ | |||
+ | Pinging VM5 from VM1: | ||
+ | < | ||
+ | root@VM1:~ # ping -c 2 10.0.45.5 | ||
+ | PING 10.0.45.5 (10.0.45.5): | ||
+ | 64 bytes from 10.0.45.5: icmp_seq=0 ttl=62 time=1.700 ms | ||
+ | 64 bytes from 10.0.45.5: icmp_seq=1 ttl=62 time=1.629 ms | ||
+ | |||
+ | --- 10.0.45.5 ping statistics --- | ||
+ | 2 packets transmitted, | ||
+ | round-trip min/ | ||
+ | root@VM1:~ # ping -c 2 2001: | ||
+ | PING6(56=40+8+8 bytes) 2001: | ||
+ | 16 bytes from 2001: | ||
+ | 16 bytes from 2001: | ||
+ | |||
+ | --- 2001: | ||
+ | 2 packets transmitted, | ||
+ | round-trip min/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | OpenVPN log file on VM2 (error installing route are due to DCO restriction): | ||
+ | < | ||
+ | Oct 4 18:29:40 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:40 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:40 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:40 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:40 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:40 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:29:41 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | Oct 4 18:30:11 VM2 openvpn[89399]: | ||
+ | </ | ||
+ | |||
+ | OpenVPN log file on VM4: | ||
+ | < | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:11 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:12 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:12 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:12 VM4 openvpn[86737]: | ||
+ | Oct 4 18:30:12 VM4 openvpn[86737]: | ||
</ | </ | ||
===== Wireguard ===== | ===== Wireguard ===== | ||
- | ==== Key pairs generation ==== | + | On current (14.0) needs only wireguard-tools (kernel module included), on older (12 or 13) needs wireguard-kmod. |
+ | ==== Key pairs generation | ||
The first step is to generate a couple of private and public keys on each wireguard endpoint. | The first step is to generate a couple of private and public keys on each wireguard endpoint. | ||
- | On VM2 and on VM4, generate the keys: | + | The standard way of generating |
< | < | ||
Line 1231: | Line 1336: | ||
</ | </ | ||
+ | But on this example, we will use static keys as example. | ||
==== Router 2 ==== | ==== Router 2 ==== | ||
- | Display router 2 private key, and router 4 public key. | + | Write example-only static |
< | < | ||
+ | echo " | ||
+ | echo " | ||
cat > / | cat > / | ||
[Interface] | [Interface] | ||
- | PrivateKey = 8Og1cCmvirK+zcGus/ | + | PrivateKey = oFsqDWpgtlma4Dy3YkPd918d3Nw9xdV9MBVn4YT1N38= |
ListenPort = 51820 | ListenPort = 51820 | ||
[Peer] | [Peer] | ||
- | PublicKey = FSvVqj2s1FZqsSIvPLrE1RRTgbaPLbfG87P36F21M1g= | + | PublicKey = o267Qf43WlVTawLq/ |
- | AllowedIPs = 10.0.45.0/ | + | AllowedIPs = 10.0.45.0/ |
Endpoint = 10.0.34.4: | Endpoint = 10.0.34.4: | ||
EOF | EOF | ||
Line 1254: | Line 1362: | ||
==== Router 4 ==== | ==== Router 4 ==== | ||
- | Display | + | Generate example-only |
< | < | ||
+ | echo " | ||
+ | echo " | ||
cat > / | cat > / | ||
[Interface] | [Interface] | ||
- | PrivateKey = ADfm6+sXZnoyDAkG/ | + | PrivateKey = 4HRXmxN77CVb5VykdNX6mqkzCh2ycu4hfWfYHTvkLGE= |
ListenPort = 51820 | ListenPort = 51820 | ||
[Peer] | [Peer] | ||
- | PublicKey = gaQij176wrz3g+2RTJ/S1oEnc7rx2reU1Z0Thrv4oXc= | + | PublicKey = z9wBhxr/K405uQeYnCoGRi6VGWu/ |
- | AllowedIPs = 10.0.12.0/ | + | AllowedIPs = 10.0.12.0/ |
Endpoint = 10.0.23.2: | Endpoint = 10.0.23.2: | ||
EOF | EOF | ||
Line 1295: | Line 1405: | ||
2 packets transmitted, | 2 packets transmitted, | ||
round-trip min/ | round-trip min/ | ||
+ | </ | ||
+ | |||
+ | Are we using the kernel module? | ||
+ | < | ||
+ | root@VM2:~ # kldstat -v -n if_wg.ko | ||
+ | Id Refs Address | ||
+ | | ||
+ | Contains modules: | ||
+ | Id Name | ||
+ | 473 wg | ||
+ | </ | ||
+ | |||
+ | Displaying wg status on VM2: | ||
+ | < | ||
+ | root@VM2:~ # ifconfig wg0 | ||
+ | wg0: flags=80c1< | ||
+ | options=80000< | ||
+ | groups: wg | ||
+ | nd6 options=101< | ||
+ | root@VM2:~ # netstat -rn | grep " | ||
+ | Destination | ||
+ | 10.0.45.0/ | ||
+ | Destination | ||
+ | 2001: | ||
+ | root@VM2:~ # wg show | ||
+ | interface: wg0 | ||
+ | public key: z9wBhxr/ | ||
+ | private key: (hidden) | ||
+ | listening port: 51820 | ||
+ | |||
+ | peer: o267Qf43WlVTawLq/ | ||
+ | endpoint: 10.0.34.4: | ||
+ | allowed ips: 2001: | ||
+ | latest handshake: 32 seconds ago | ||
+ | transfer: 356 B received, 436 B sent | ||
</ | </ |
documentation/examples/gre_ipsec_and_openvpn.1664889049.txt.gz · Last modified: 2022/10/04 15:10 by olivier