fixed pihole server via prerouting
This commit is contained in:
@@ -30,20 +30,19 @@
|
|||||||
cap_add:
|
cap_add:
|
||||||
- CAP_NET_BIND_SERVICE
|
- CAP_NET_BIND_SERVICE
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
network:
|
|
||||||
- host
|
|
||||||
env:
|
env:
|
||||||
DNSMASQ_USER: "root"
|
DNSMASQ_USER: "root"
|
||||||
|
INTERFACE: "tap0"
|
||||||
PIHOLE_UID: 0
|
PIHOLE_UID: 0
|
||||||
TZ: "America/New_York"
|
TZ: "America/New_York"
|
||||||
|
VIRTUAL_HOST: "{{ pi_server_name }}"
|
||||||
WEBPASSWORD: "{{ pihole_password }}"
|
WEBPASSWORD: "{{ pihole_password }}"
|
||||||
WEB_PORT: 8082
|
|
||||||
volumes:
|
volumes:
|
||||||
- "{{ pihole_path }}/config:/etc/pihole"
|
- "{{ pihole_path }}/config:/etc/pihole"
|
||||||
- "{{ pihole_path }}/dnsmasq:/etc/dnsmasq.d"
|
- "{{ pihole_path }}/dnsmasq:/etc/dnsmasq.d"
|
||||||
ports:
|
ports:
|
||||||
- 53:53/udp
|
- 1153:53/udp
|
||||||
- 53:53/tcp
|
- 1153:53/tcp
|
||||||
- 8082:80
|
- 8082:80
|
||||||
tags: pihole
|
tags: pihole
|
||||||
|
|
||||||
@@ -52,3 +51,22 @@
|
|||||||
vars:
|
vars:
|
||||||
container_name: pihole
|
container_name: pihole
|
||||||
tags: pihole
|
tags: pihole
|
||||||
|
|
||||||
|
- name: Redirect DNS, DHCP, HTTP and HTTPS to pihole
|
||||||
|
become: true
|
||||||
|
ansible.builtin.iptables:
|
||||||
|
table: nat
|
||||||
|
chain: PREROUTING
|
||||||
|
in_interface: eno1
|
||||||
|
protocol: "{{ item }}"
|
||||||
|
match: "{{ item }}"
|
||||||
|
destination_port: 53
|
||||||
|
jump: REDIRECT
|
||||||
|
to_ports: 1153
|
||||||
|
comment: Redirect DNS traffic to port 1153
|
||||||
|
loop:
|
||||||
|
- udp
|
||||||
|
- tcp
|
||||||
|
tags:
|
||||||
|
- pihole
|
||||||
|
- firewall
|
||||||
|
|||||||
@@ -4,16 +4,18 @@
|
|||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
port: "{{ item }}"
|
port: "{{ item }}"
|
||||||
permanent: true
|
permanent: true
|
||||||
|
immediate: true
|
||||||
|
zone: "public"
|
||||||
state: enabled
|
state: enabled
|
||||||
loop:
|
loop:
|
||||||
- 53/tcp
|
- 53/tcp
|
||||||
- 53/udp
|
- 53/udp
|
||||||
|
- 1153/tcp
|
||||||
|
- 1153/udp
|
||||||
- 80/tcp
|
- 80/tcp
|
||||||
- 443/tcp
|
- 443/tcp
|
||||||
- "{{ syslog_udp_default }}/udp"
|
- "{{ syslog_udp_default }}/udp"
|
||||||
- "{{ syslog_udp_error }}/udp"
|
- "{{ syslog_udp_error }}/udp"
|
||||||
- "{{ syslog_udp_unifi }}/udp"
|
- "{{ syslog_udp_unifi }}/udp"
|
||||||
notify: restart firewalld
|
notify: restart firewalld
|
||||||
tags:
|
tags: firewall
|
||||||
- firewall
|
|
||||||
- http
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
become: true
|
become: true
|
||||||
ansible.posix.sysctl:
|
ansible.posix.sysctl:
|
||||||
name: net.ipv4.ip_unprivileged_port_start
|
name: net.ipv4.ip_unprivileged_port_start
|
||||||
value: "53"
|
value: "80"
|
||||||
sysctl_set: true
|
sysctl_set: true
|
||||||
state: present
|
state: present
|
||||||
reload: true
|
reload: true
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ server {
|
|||||||
allow 127.0.0.1;
|
allow 127.0.0.1;
|
||||||
deny all;
|
deny all;
|
||||||
|
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection $connection_upgrade;
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_pass http://pihole;
|
proxy_pass http://pihole;
|
||||||
|
|||||||
Reference in New Issue
Block a user