roles/networking: fix dns issues

This commit is contained in:
dogeystamp 2023-08-27 14:50:34 -04:00
parent 3b1cfcf61a
commit d6a1876fe8
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
4 changed files with 27 additions and 2 deletions

View File

@ -9,3 +9,6 @@ subnet_prefix: /24
local_subnet: 192.168.0.0/24
# router IP address
gateway: 192.168.0.1
# Can be the server itself if it has a nameserver
nameserver: "{{ hostvars[groups['nameserver'][0]]['local_ip'] }}"

View File

@ -38,9 +38,24 @@
job: "/root/rmconn.sh"
state: present
- name: Disable DHCP DNS
template:
src: nodns.network.j2
dest: /etc/systemd/network/50-nodns.network
- name: Create resolved configuration directory
file:
path: /etc/systemd/resolved.conf.d
state: directory
- name: Set DNS
template:
src: dns_servers.conf.j2
dest: /etc/systemd/resolved.conf.d/50-dns_servers.conf
- name: Create NetworkManager connection
community.general.nmcli:
dns4: "{{ local_ip }}"
dns4: "{{ nameserver }}"
dns4_ignore_auto: yes
ip4: "{{ local_ip }}{{ subnet_prefix }}"
gw4: "{{ gateway }}"
@ -57,7 +72,7 @@
- name: Attempt to reconnect
wait_for_connection:
timeout: 240
when: nmcli_conf.changed
when: nmcli_conf.changed or rmconn.changed
- name: Remove rmconn task at every minute
cron:

View File

@ -0,0 +1,2 @@
[Resolve]
DNS={{ nameserver }}

View File

@ -0,0 +1,5 @@
[Match]
Name=*
[DHCP]
UseDNS=false