fix(netbird): отключить IPv6/DNS-перехват на Exit Node и сузить маршрут LAN
ansible-ger-nod-02 / deploy (push) Failing after 43s
ansible-rus-central / deploy (push) Successful in 58s

This commit is contained in:
karpenok committed 2026-11-15 11:59:40 +07:00
1 parent 4884a61ad2
commit c90a78e160
3 files changed
+49 -17

No files matched your search

@@ -5,6 +5,12 @@
content: |
net.ipv4.ip_forward = 1
net.ipv4.conf.all.src_valid_mark = 1
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
owner: root
group: root
mode: "0644"
@@ -24,6 +30,12 @@
ansible.builtin.include_role:
name: netbird_client
- name: Перезапустить NetBird после изменения sysctl
ansible.builtin.systemd:
name: netbird
state: restarted
when: netbird_exit_sysctl is changed
- name: Установить jq для синхронизации Exit Node через API NetBird
ansible.builtin.apt:
name: jq
@@ -84,8 +96,13 @@
exit_clients_group_id=$(printf '%s' "${groups_json}" | jq -r --arg g "${NB_EXIT_CLIENTS_GROUP}" '.[] | select(.name == $g) | .id' | head -n 1)
if [ -n "${exit_clients_group_id}" ]; then
routes_json=$(curl -fsS --max-time 20 -H "Authorization: Token ${NB_API_TOKEN}" "${API_BASE}/routes")
existing_exit_route_id=$(printf '%s' "${routes_json}" | jq -r --arg nid "${NB_EXIT_NET_ID}" '.[] | select(.network_id == $nid and .network == "0.0.0.0/0") | .id' | head -n 1)
if [ -z "${existing_exit_route_id}" ]; then
existing_exit_route=$(printf '%s' "${routes_json}" | jq -c --arg nid "${NB_EXIT_NET_ID}" '.[] | select(.network_id == $nid and .network == "0.0.0.0/0")' | head -n 1)
existing_exit_route_id=$(printf '%s' "${existing_exit_route}" | jq -r '.id // empty')
needs_exit_route_update="false"
if [ -n "${existing_exit_route_id}" ]; then
needs_exit_route_update=$(printf '%s' "${existing_exit_route}" | jq -r '(.metric != 9999) or (.keep_route != false)')
fi
if [ -z "${existing_exit_route_id}" ] || [ "${needs_exit_route_update}" = "true" ]; then
exit_route_payload=$(jq -n \
--arg desc "Exit Node DE (0.0.0.0/0 via ${NB_PEER_HOST})" \
--arg nid "${NB_EXIT_NET_ID}" \
@@ -97,13 +114,17 @@
enabled: true,
peer_groups: [$eg],
network: "0.0.0.0/0",
metric: 100,
metric: 9999,
masquerade: true,
groups: [$cg],
keep_route: true,
keep_route: false,
skip_auto_apply: false
}')
nb_api_call POST "/routes" "${exit_route_payload}" >/dev/null
if [ -z "${existing_exit_route_id}" ]; then
nb_api_call POST "/routes" "${exit_route_payload}" >/dev/null
else
nb_api_call PUT "/routes/${existing_exit_route_id}" "${exit_route_payload}" >/dev/null
fi
exit_route_created=1
fi
fi