Attempted fix for udp forwarding

This commit is contained in:
Philip (a-0) 2022-07-27 11:30:37 +02:00
parent 5b508f2f87
commit b867164902
2 changed files with 21 additions and 23 deletions

View file

@ -1,4 +1,9 @@
---
- name: Install required packages
apt:
name: socat
state: present
- name: Ensure unprivileged ssh user exists
user:
name: "{{ ssh_tunnel_sshd_unprivileged_user }}"
@ -81,18 +86,10 @@
- name: Forward privileged ports to ephemeral localhost ports (IPv4, UDP)
become: yes
iptables:
ip_version: ipv4
table: nat
chain: PREROUTING
in_interface: eth0
protocol: udp
destination_port: "{{ item.exposed_port }}"
jump: DNAT
to_destination: "127.0.0.1:{{ item.ephemeral_port }}"
shell:
command: "socat -T10 udp4-recvfrom:{{ item.exposed_port }},fork tcp:127.0.0.1:{{ item.ephemeral_port }}"
loop: "{{ tunneled_ports }}"
when: "'udp' in item.protocols"
notify: persist iptables
- name: Forward privileged ports to ephemeral localhost ports (IPv6, TCP)
become: yes
@ -111,15 +108,7 @@
- name: Forward privileged ports to ephemeral localhost ports (IPv6, UDP)
become: yes
iptables:
ip_version: ipv6
table: nat
chain: PREROUTING
in_interface: eth0
protocol: udp
destination_port: "{{ item.exposed_port }}"
jump: DNAT
to_destination: "[::1]:{{ item.ephemeral_port }}"
shell:
command: "socat -T10 udp6-recvfrom:{{ item.exposed_port }},fork tcp:[::1]:{{ item.ephemeral_port }}"
loop: "{{ tunneled_ports }}"
when: "'udp' in item.protocols"
notify: persist iptables
when: "'udp' in item.protocols"