wrk 2024-08-27 12-44-17
Проброс порта
---
- name: Redirect traffic from 127.0.0.1:8888 to 192.168.122.249:80
hosts: localhost
become: yes # Используйте sudo для выполнения команд
tasks:
- name: Add DNAT rule to redirect traffic
iptables:
chain: OUTPUT
protocol: tcp
destination: 127.0.0.1
dport: 8888
jump: DNAT
to_destination: 192.168.122.249:80
state: present
- name: Allow forwarding to 192.168.122.249
iptables:
chain: FORWARD
protocol: tcp
destination: 192.168.122.249
dport: 80
jump: ACCEPT
state: present
---------------------------
iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to-destination 192.168.0.10:3306
iptables -A FORWARD -p tcp -d 192.168.0.10 --dport 3306 -j ACCEPT
удалить маршрут
iptables -t nat -D PREROUTING -p tcp --dport 3306 -j DNAT --to-destination 192.168.0.10:3306
iptables -D FORWARD -p tcp -d 192.168.0.10 --dport 3306 -j ACCEPT
записать на постоянно
service iptables save # для CentOS
iptables-save > /etc/iptables/rules.v4 # для Debian/Ubuntu
2024-08-28_06-57-09