Files
vpn-node-config/README.md
T
gitea_admin 6046e3a406
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 10s
OpenVPN Ansible / Ansible Lint (push) Successful in 17s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Failing after 9s
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped
feat(ansible): automate NAT gateway and VPN routing
- Add NAT gateway inventory and routing playbooks.
- Update Gitea Actions and GitLab CI to validate all playbooks.
- Deploy gateway and routing configurations before OpenVPN.
- Document setup and verification steps.
2026-10-28 18:15:58 +01:00

89 lines
3.5 KiB
Markdown

# VPN node configuration
Ansible configuration for Ubuntu 24.04 VPN nodes. Host packages are installed
through Ubuntu's package manager, so package architecture selection is
automatic.
## Supported platforms
- `linux/amd64` (`x86_64`)
- `linux/arm64` (`aarch64`)
The common role checks the Ubuntu release and architecture before
making changes. Networking sysctl configuration uses the interfaces reported
by Ansible rather than assuming a particular NIC name. The OpenVPN RADIUS
plugin path is discovered after package installation, including Debian's
architecture-specific library directories.
## Run
Configure inventory in `inventories/prod/hosts.ini`, then run:
```sh
ansible-playbook playbooks/openvpn.yml
```
The target hosts must run Ubuntu 24.04 and Ansible must gather facts.
## Private VM internet access
The `vpn-gateway` VM provides NAT for private VPN nodes. A private VM sends
internet-bound traffic to the Hetzner private-network router (`10.0.0.1`). The
Hetzner network route for `0.0.0.0/0` then delivers it to the gateway's private
address (`10.100.0.4`), where iptables masquerades it out `eth0`. The route in
Hetzner's network and the operating-system default route on each private VM are
separate settings: both must exist. The gateway itself keeps its public default
route through `eth0`.
`vpn_nodes` contains private VPN nodes and `nat_gateways` contains only the
gateway. Add new private VMs to `vpn_nodes` with their management address and
private address, and set the private routing role variables in host/group vars
if their interface or gateway differs. Do not add a gateway to `vpn_nodes`.
The routing role detects Netplan or systemd-networkd and adds only a route
fragment; review the host's existing route metrics and manager before rollout.
The Netplan fragment adds a metric 100 default route. Internal destinations
continue to use more-specific routes; validate the FreeRADIUS NodePort path on
each host.
Install required collections with `ansible-galaxy collection install -r
requirements.yml`, then check syntax and deploy independently:
```sh
ansible-playbook --syntax-check playbooks/nat-gateway.yml
ansible-playbook --syntax-check playbooks/private-vpn-routing.yml
ansible-playbook --check playbooks/nat-gateway.yml --limit nat_gateways
ansible-playbook playbooks/nat-gateway.yml --limit nat_gateways
ansible-playbook --check playbooks/private-vpn-routing.yml --limit vpn_nodes
ansible-playbook playbooks/private-vpn-routing.yml --limit vpn_nodes
```
Check mode cannot validate actual kernel routes or persistence and may report
handlers without applying them. `netplan apply` and restarting
systemd-networkd can briefly interrupt remote connectivity; schedule route
rollout with console access or a maintenance window. Do not reboot automatically.
Verify the gateway after deployment (and separately after a planned reboot):
```sh
sysctl net.ipv4.ip_forward
iptables -t nat -S POSTROUTING
iptables -S FORWARD
sudo netfilter-persistent save
ip -4 route show default
```
Expect forwarding value `1`, the subnet-specific MASQUERADE and two narrow
FORWARD rules, and the gateway public default via `eth0`. On each private VM:
```sh
ip -4 route show default
ip -4 route get 8.8.8.8
getent hosts google.com
curl -I --max-time 10 https://google.com
```
Also connect to the existing FreeRADIUS NodePort endpoint using its configured
address and port. DNS and NodePort checks require live network access. The
inventory gateway IP/interface values are taken from the supplied task; verify
them against the live Hetzner VM before applying.