fix(private_routing): add DNS nameservers to Netplan/networkd route config
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 9s
OpenVPN Ansible / Ansible Lint (push) Successful in 18s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Successful in 1m54s
OpenVPN Ansible / Generate SBOM (push) Successful in 54s
OpenVPN Ansible / Scan SBOM with Trivy (push) Successful in 18s
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 9s
OpenVPN Ansible / Ansible Lint (push) Successful in 18s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Successful in 1m54s
OpenVPN Ansible / Generate SBOM (push) Successful in 54s
OpenVPN Ansible / Scan SBOM with Trivy (push) Successful in 18s
This commit is contained in:
@@ -2,3 +2,6 @@
|
|||||||
private_routing_interface: enp7s0
|
private_routing_interface: enp7s0
|
||||||
private_routing_gateway: 10.0.0.1
|
private_routing_gateway: 10.0.0.1
|
||||||
private_routing_metric: 100
|
private_routing_metric: 100
|
||||||
|
private_routing_nameservers:
|
||||||
|
- 1.1.1.1
|
||||||
|
- 9.9.9.9
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
No Netplan configuration or active systemd-networkd interface found for
|
No Netplan configuration or active systemd-networkd interface found for
|
||||||
{{ private_routing_interface }}; refusing to change network configuration.
|
{{ private_routing_interface }}; refusing to change network configuration.
|
||||||
|
|
||||||
|
# ---- Netplan path ----
|
||||||
- name: Install Netplan route drop-in
|
- name: Install Netplan route drop-in
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/netplan/99-private-vpn-default-route.yaml
|
dest: /etc/netplan/99-private-vpn-default-route.yaml
|
||||||
@@ -32,9 +33,11 @@
|
|||||||
ethernets:
|
ethernets:
|
||||||
{{ private_routing_interface }}:
|
{{ private_routing_interface }}:
|
||||||
routes:
|
routes:
|
||||||
- to: 0.0.0.0/0
|
- to: default
|
||||||
via: {{ private_routing_gateway }}
|
via: {{ private_routing_gateway }}
|
||||||
metric: {{ private_routing_metric }}
|
metric: {{ private_routing_metric }}
|
||||||
|
nameservers:
|
||||||
|
addresses: {{ private_routing_nameservers | to_json }}
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
@@ -46,6 +49,7 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
when: private_routing_netplan_files.matched | default(0) > 0
|
when: private_routing_netplan_files.matched | default(0) > 0
|
||||||
|
|
||||||
|
# ---- systemd-networkd path ----
|
||||||
- name: Install systemd-networkd route drop-in
|
- name: Install systemd-networkd route drop-in
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: "/etc/systemd/network/90-{{ private_routing_interface }}-private-vpn-route.network"
|
dest: "/etc/systemd/network/90-{{ private_routing_interface }}-private-vpn-route.network"
|
||||||
@@ -53,6 +57,11 @@
|
|||||||
[Match]
|
[Match]
|
||||||
Name={{ private_routing_interface }}
|
Name={{ private_routing_interface }}
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
{% for ns in private_routing_nameservers %}
|
||||||
|
DNS={{ ns }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
[Route]
|
[Route]
|
||||||
Destination=0.0.0.0/0
|
Destination=0.0.0.0/0
|
||||||
Gateway={{ private_routing_gateway }}
|
Gateway={{ private_routing_gateway }}
|
||||||
@@ -68,8 +77,17 @@
|
|||||||
state: restarted
|
state: restarted
|
||||||
when: private_routing_netplan_files.matched | default(0) == 0
|
when: private_routing_netplan_files.matched | default(0) == 0
|
||||||
|
|
||||||
|
# ---- Verification (both paths) ----
|
||||||
- name: Verify selected route to internet
|
- name: Verify selected route to internet
|
||||||
ansible.builtin.command: ip -4 route get 8.8.8.8
|
ansible.builtin.command: ip -4 route get 8.8.8.8
|
||||||
register: private_route_get
|
register: private_route_get
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: private_routing_gateway not in private_route_get.stdout or private_routing_interface not in private_route_get.stdout
|
failed_when: private_routing_gateway not in private_route_get.stdout or private_routing_interface not in private_route_get.stdout
|
||||||
|
|
||||||
|
- name: Verify DNS resolution through the gateway
|
||||||
|
ansible.builtin.command: getent hosts archive.ubuntu.com
|
||||||
|
register: private_dns_check
|
||||||
|
changed_when: false
|
||||||
|
retries: 5
|
||||||
|
delay: 3
|
||||||
|
until: private_dns_check.rc == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user