chore: добавлен скрипт для создания прозрачного прокси из сервера

This commit is contained in:
protokey committed 2026-09-26 13:20:25 +04:00
1 parent 064bb70f32
commit 9bb3a2fc5d
7 files changed
+100 -14

No files matched your search

+27 -3
View File
@@ -1,6 +1,6 @@
# extravars: target_ip
# extravars: target_ip, ports
#
# Превращает сервер в прозрачный прокси: весь трафик, кроме ssh, уходит на target_ip.
# Превращает сервер в прозрачный прокси: tcp-порты ports уходят на те же порты target_ip.
- name: Redirect traffic to target
hosts: target
gather_facts: false
@@ -10,12 +10,35 @@
firewall_tcp_ports: [ "{{ ansible_port }}" ]
firewall_forward: true
# sysctl при загрузке применяется раньше nftables: без модулей ключи conntrack и bbr не выставятся
- name: Load forwarding kernel modules on boot
ansible.builtin.copy:
dest: /etc/modules-load.d/serverus-forward.conf
mode: "0644"
content: |
nf_conntrack
tcp_bbr
- name: Load forwarding kernel modules
ansible.builtin.command: modprobe -a nf_conntrack tcp_bbr
changed_when: false
- name: Enable ip forwarding
ansible.builtin.copy:
dest: /etc/sysctl.d/90-serverus-forward.conf
mode: "0644"
content: |
net.ipv4.ip_forward = 1
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.netfilter.nf_conntrack_max = 2000000
net.core.netdev_max_backlog = 250000
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_slow_start_after_idle = 0
- name: Apply sysctl
ansible.builtin.command: sysctl --system
@@ -28,6 +51,7 @@
mode: "0755"
- name: Redirect traffic
ansible.builtin.command: "/usr/local/sbin/serverus-redirect {{ target_ip }}"
ansible.builtin.command:
argv: [ /usr/local/sbin/serverus-redirect, "{{ target_ip }}", "{{ ports | join(',') }}" ]
environment:
SSH_PORT: "{{ ansible_port }}"