mirror of
https://github.com/itdoginfo/ansible-openwrt-hirkn.git
synced 2025-12-16 12:04:30 +05:00
Added wg_access and fixed dnsmasq check issue
This commit is contained in:
@@ -28,7 +28,7 @@ wget https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/ge
|
|||||||
|
|
||||||
- OpenWrt 21.02.7
|
- OpenWrt 21.02.7
|
||||||
- OpenWrt 22.03.5
|
- OpenWrt 22.03.5
|
||||||
- OpenWrt 23.05.0
|
- OpenWrt 23.05.2
|
||||||
|
|
||||||
### Выбор туннеля
|
### Выбор туннеля
|
||||||
- Wireguard настраивается автоматически через переменные
|
- Wireguard настраивается автоматически через переменные
|
||||||
@@ -56,6 +56,8 @@ wget https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/ge
|
|||||||
|
|
||||||
Остальное можно менять, в зависимости от того, как настроен wireguard сервер
|
Остальное можно менять, в зависимости от того, как настроен wireguard сервер
|
||||||
|
|
||||||
|
**wg_access** и **wg_access_network** для доступа к роутеру через WG
|
||||||
|
|
||||||
### Шифрование DNS
|
### Шифрование DNS
|
||||||
Если ваш провайдер не подменяет DNS-запросы, ничего устанавливать не нужно.
|
Если ваш провайдер не подменяет DNS-запросы, ничего устанавливать не нужно.
|
||||||
|
|
||||||
@@ -70,6 +72,8 @@ wget https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/ge
|
|||||||
- russia-outside
|
- russia-outside
|
||||||
- ukraine
|
- ukraine
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
### Списки IP-адресов и домены
|
### Списки IP-адресов и домены
|
||||||
Переменные **list_** обозначают, какие списки нужно установить. true - установить, false - не устанавливать и удалить, если уже есть
|
Переменные **list_** обозначают, какие списки нужно установить. true - установить, false - не устанавливать и удалить, если уже есть
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
tunnel: wg
|
tunnel: wg
|
||||||
dns_encrypt: false
|
dns_encrypt: false
|
||||||
country: russia-inside
|
country: russia-inside
|
||||||
|
nano: true
|
||||||
|
|
||||||
wg_server_address: wg-server-host
|
wg_server_address: wg-server-host
|
||||||
wg_private_key: privatekey-client
|
wg_private_key: privatekey-client
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
wg_listen_port: 51820
|
wg_listen_port: 51820
|
||||||
wg_client_port: 51820
|
wg_client_port: 51820
|
||||||
wg_client_address: ip-client
|
wg_client_address: ip-client
|
||||||
|
wg_access: false
|
||||||
|
wg_access_network: wg-network (for example: 192.168.10.0/24)
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
# Dnsmasq version check
|
# Dnsmasq version check
|
||||||
@@ -63,13 +66,20 @@
|
|||||||
- sing-box
|
- sing-box
|
||||||
when: tunnel == "singbox" and ansible_distribution_major_version >= "23"
|
when: tunnel == "singbox" and ansible_distribution_major_version >= "23"
|
||||||
|
|
||||||
- name: install curl and nano
|
- name: install curl
|
||||||
opkg:
|
opkg:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
loop:
|
loop:
|
||||||
- curl
|
- curl
|
||||||
|
|
||||||
|
- name: install nano
|
||||||
|
opkg:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop:
|
||||||
- nano
|
- nano
|
||||||
|
when: nano
|
||||||
|
|
||||||
- name: install ipset
|
- name: install ipset
|
||||||
opkg:
|
opkg:
|
||||||
@@ -120,56 +130,6 @@
|
|||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
# Configure route table
|
# Configure route table
|
||||||
|
|
||||||
# - name: Create vpn0 interface
|
|
||||||
# uci:
|
|
||||||
# command: section
|
|
||||||
# config: network
|
|
||||||
# type: interface
|
|
||||||
# find_by:
|
|
||||||
# name: vpn0
|
|
||||||
# name: vpn0
|
|
||||||
# value:
|
|
||||||
# name: vpn0
|
|
||||||
# proto: none
|
|
||||||
# auto: 1
|
|
||||||
# device: tun0
|
|
||||||
# when: tunnel == "openvpn" or tunnel == "singbox" or tunnel == "tun2socks"
|
|
||||||
# notify:
|
|
||||||
# - Restart network
|
|
||||||
|
|
||||||
# - name: tunnel routing. tun0
|
|
||||||
# uci:
|
|
||||||
# command: section
|
|
||||||
# config: network
|
|
||||||
# type: route
|
|
||||||
# find_by:
|
|
||||||
# name: vpn_route
|
|
||||||
# name: vpn_route
|
|
||||||
# value:
|
|
||||||
# name: vpn_route
|
|
||||||
# interface: vpn0
|
|
||||||
# table: vpn
|
|
||||||
# target: 0.0.0.0/0
|
|
||||||
# when: tunnel == "openvpn" or tunnel == "singbox" or tunnel == "tun2socks"
|
|
||||||
# notify:
|
|
||||||
# - Restart network
|
|
||||||
|
|
||||||
# - name: tunnel routing. wg0
|
|
||||||
# uci:
|
|
||||||
# command: section
|
|
||||||
# config: network
|
|
||||||
# type: route
|
|
||||||
# find_by:
|
|
||||||
# name: vpn
|
|
||||||
# name: vpn_route
|
|
||||||
# value:
|
|
||||||
# interface: wg0
|
|
||||||
# table: vpn
|
|
||||||
# target: 0.0.0.0/0
|
|
||||||
# when: tunnel == "wg"
|
|
||||||
# notify:
|
|
||||||
# - Restart network
|
|
||||||
|
|
||||||
- name: Route for vpn table
|
- name: Route for vpn table
|
||||||
template:
|
template:
|
||||||
@@ -483,7 +443,6 @@
|
|||||||
value:
|
value:
|
||||||
match: dst_net
|
match: dst_net
|
||||||
storage: hash
|
storage: hash
|
||||||
failed_when: ansible_distribution_major_version < "22" and list_domains and not dnsmasqfull_version.stdout
|
|
||||||
when: ansible_distribution_major_version < "22" and list_domains
|
when: ansible_distribution_major_version < "22" and list_domains
|
||||||
|
|
||||||
- name: add nfset for domains (>=22). If failed, repeat playbook. If failed is repeated check dnsmasq-full.
|
- name: add nfset for domains (>=22). If failed, repeat playbook. If failed is repeated check dnsmasq-full.
|
||||||
@@ -495,7 +454,6 @@
|
|||||||
name: vpn_domains
|
name: vpn_domains
|
||||||
value:
|
value:
|
||||||
match: dst_net
|
match: dst_net
|
||||||
failed_when: ansible_distribution_major_version >= "22" and list_domains and (not dnsmasqfull_version.stdout or dnsmasqfull_version.stdout < "2.87")
|
|
||||||
when: ansible_distribution_major_version >= "22" and list_domains
|
when: ansible_distribution_major_version >= "22" and list_domains
|
||||||
|
|
||||||
- name: add mark rule vpn_subnet
|
- name: add mark rule vpn_subnet
|
||||||
@@ -564,7 +522,30 @@
|
|||||||
set_mark: "0x1"
|
set_mark: "0x1"
|
||||||
target: MARK
|
target: MARK
|
||||||
family: ipv4
|
family: ipv4
|
||||||
when: (ansible_distribution_major_version < "22" and list_domains and dnsmasqfull_version.stdout) or (ansible_distribution_major_version >= "22" and list_domains and dnsmasqfull_version.stdout >= "2.87")
|
when: (ansible_distribution_major_version < "22" and list_domains) or (ansible_distribution_major_version >= "22" and list_domains)
|
||||||
|
|
||||||
|
- name: wg access route
|
||||||
|
uci:
|
||||||
|
command: section
|
||||||
|
config: network
|
||||||
|
type: route
|
||||||
|
find_by:
|
||||||
|
name: wg_access_route
|
||||||
|
value:
|
||||||
|
interface: wg0
|
||||||
|
target: "{{ wg_access_network }}"
|
||||||
|
when: wg_access
|
||||||
|
|
||||||
|
- name: set WG firewall zone
|
||||||
|
uci:
|
||||||
|
command: section
|
||||||
|
config: firewall
|
||||||
|
type: zone
|
||||||
|
find_by:
|
||||||
|
name: wg
|
||||||
|
value:
|
||||||
|
input: ACCEPT
|
||||||
|
when: wg_access
|
||||||
|
|
||||||
# Remove unused rules and ipset
|
# Remove unused rules and ipset
|
||||||
- name: Remove ipset for ip
|
- name: Remove ipset for ip
|
||||||
|
|||||||
Reference in New Issue
Block a user