| --- |
|
|
| - block: |
| - name: Alias port |
| iptables: |
| table: nat |
| chain: PREROUTING |
| in_interface: "{{ ansible_default_ipv4.interface }}" |
| protocol: "{{ item.protocol }}" |
| destination: "{{ item.destination }}" |
| # destination: "{{ interfaces.0.private_ip_real }}" |
| destination_port: "{{ item.original_port }}" |
| jump: DNAT |
| to_destination: "{{ item.destination }}:{{ item.new_port }}" |
| # to_destination: "{{ interfaces.0.private_ip_real }}:{{ item.dest_port }}" |
| comment: "{{ item.comment }}" |
| notify: iptables-save-rules |
| loop: "{{ iptables_port_aliases }}" |
|
|
| - name: Masquerade traffic |
| iptables: |
| table: nat |
| chain: POSTROUTING |
| protocol: '{{ item.protocol | d(omit) }}' |
| destination: '{{ item.destination }}' |
| destination_port: "{{ item.destination_port | d(omit) }}" |
| source: "{{ item.source | d(omit) }}" |
| source_port: "{{ item.source_port | d(omit) }}" |
| jump: MASQUERADE |
| comment: '{{ item.comment }}' |
| notify: iptables-save-rules |
| loop: "{{ iptables_masquerade }}" |
| when: ansible_os_family != 'Windows' |