This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
technical:ipsec:strongswan [2023/04/07 15:34] – jc | technical:ipsec:strongswan [2023/06/12 10:52] (current) – jc | ||
---|---|---|---|
Line 4: | Line 4: | ||
# Install | # Install | ||
Install the strongswan package from fedora package repository. | Install the strongswan package from fedora package repository. | ||
- | ``` | + | ```bash |
dnf install -y strongswan | dnf install -y strongswan | ||
``` | ``` | ||
# Configuration | # Configuration | ||
+ | ## IP Forwarding | ||
+ | Enable IPv4 traffic forwarding on both VPN sites. | ||
+ | / | ||
+ | ```bash | ||
+ | net.ipv4.ip_forward = 1 | ||
+ | ``` | ||
+ | Reload sysctl settings | ||
+ | ```bash | ||
+ | sysctl -p | ||
+ | ``` | ||
## Network | ## Network | ||
Configure a network interface for the WAN connection between VPNs and a network interface for the LAN host network. | Configure a network interface for the WAN connection between VPNs and a network interface for the LAN host network. | ||
### VPN-Site-1 | ### VPN-Site-1 | ||
- | ``` | + | ```bash |
nmcli connection add ifname ens4 connection.id wan connection.type 802-3-ethernet mtu 1460 ipv4.method manual ipv4.address 100.64.20.1/ | nmcli connection add ifname ens4 connection.id wan connection.type 802-3-ethernet mtu 1460 ipv4.method manual ipv4.address 100.64.20.1/ | ||
nmcli connection add ifname ens5 connection.id lan connection.type 802-3-ethernet ipv4.method manual ipv4.address 192.168.80.1/ | nmcli connection add ifname ens5 connection.id lan connection.type 802-3-ethernet ipv4.method manual ipv4.address 192.168.80.1/ | ||
+ | nmcli connection reload | ||
``` | ``` | ||
### VPN-Site-2 | ### VPN-Site-2 | ||
- | ``` | + | ```bash |
nmcli connection add ifname ens4 connection.id wan connection.type 802-3-ethernet mtu 1460 ipv4.method manual ipv4.address 100.64.20.2/ | nmcli connection add ifname ens4 connection.id wan connection.type 802-3-ethernet mtu 1460 ipv4.method manual ipv4.address 100.64.20.2/ | ||
nmcli connection add ifname ens5 connection.id lan connection.type 802-3-ethernet ipv4.method manual ipv4.address 192.168.90.1/ | nmcli connection add ifname ens5 connection.id lan connection.type 802-3-ethernet ipv4.method manual ipv4.address 192.168.90.1/ | ||
+ | nmcli connection reload | ||
+ | ``` | ||
+ | ## Firewall | ||
+ | Configure firewall rules for both VPN sites. | ||
+ | ```bash | ||
+ | firewall-cmd --permanent --add-zone=wan | ||
+ | firewall-cmd --permanent --change-zone=ens4 --zone=wan | ||
+ | firewall-cmd --zone=wan --permanent --add-rich-rule=' | ||
+ | firewall-cmd --zone=wan --permanent --add-rich-rule=' | ||
+ | firewall-cmd --zone=wan --permanent --add-port=500/ | ||
+ | firewall-cmd --zone=wan --permanent --add-port=4500/ | ||
+ | firewall-cmd --zone=wan --permanent --add-service=" | ||
+ | firewall-cmd --reload | ||
``` | ``` | ||
## Certificates | ## Certificates | ||
1. Generate and sign certificates and private keys for both VPN sites. | 1. Generate and sign certificates and private keys for both VPN sites. | ||
- | 2. Copy the CA certificate, | + | 2. Copy the CA certificate, |
- | ``` | + | ```bash |
cp < | cp < | ||
- | cp <vpn_cert> / | + | cp <server_cert> / |
cp < | cp < | ||
+ | ``` | ||
+ | |||
+ | 3. Add the CA certificate to the certificate trust store. | ||
+ | ```bash | ||
+ | cp < | ||
+ | update-ca-trust | ||
``` | ``` | ||
## VPN | ## VPN | ||
+ | The default `left` site is local and the `right` site is remote, however you can designate either site as left or right. | ||
### VPN-Site-1 | ### VPN-Site-1 | ||
/ | / | ||
Line 99: | Line 130: | ||
# Run | # Run | ||
Start the VPN. | Start the VPN. | ||
- | ``` | + | ```bash |
strongswan start | strongswan start | ||
+ | ``` | ||
+ | |||
+ | The legacy systemd unit can configured by enabling the `strongswan-starter.service` script. | ||
+ | ```bash | ||
+ | systemctl enable strongswan-starter.service | ||
+ | systemctl start strongswan-starter.service | ||
``` | ``` | ||
# Links | # Links | ||
Line 106: | Line 143: | ||
* http:// | * http:// | ||
</ | </ | ||
+ |