-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_nat_rules.yml
104 lines (102 loc) · 2.89 KB
/
create_nat_rules.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# FILENAME
# create_nat_rule.yml
#
# DESCRIPTION
# Used to provision NAT rules on PAN-OS appliances
#
# REQUIREMENTS
# pip install ansible
# ansible-galaxy install PaloAltoNetworks.paloaltonetworks
# create vars.yml and configure with your credentials
#
# EXECUTE
# ansible-playbook create_nat_rule.yml
---
- hosts: localhost
connection: local
gather_facts: False
roles:
- role: PaloAltoNetworks.paloaltonetworks
tasks:
- name: inbound-to-linux-80
panos_nat_rule:
ip_address: "{{ mgmt_ip }}"
username: ""
password: ""
api_key : "{{ apikey }}"
operation: 'add'
rule_name: "inbound-to-linux-80"
source_zone: ["internet"]
destination_zone: "internet"
source_ip: ["any"]
destination_ip: ["{{ untrust_ip }}"]
service: "tcp-80"
snat_type: "dynamic-ip-and-port"
snat_interface: "ethernet1/2"
dnat_address: "{{ linux_ip }}"
dnat_port: "80"
commit: "False"
- name: inbound-to-linux-8080
panos_nat_rule:
ip_address: "{{ mgmt_ip }}"
username: ""
password: ""
api_key : "{{ apikey }}"
operation: 'add'
rule_name: "inbound-to-linux-8080"
source_zone: ["internet"]
destination_zone: "internet"
source_ip: ["any"]
destination_ip: ["{{ untrust_ip }}"]
service: "tcp-8080"
snat_type: "dynamic-ip-and-port"
snat_interface: "ethernet1/2"
dnat_address: "{{ linux_ip }}"
dnat_port: "8080"
commit: "False"
- name: inbound-to-linux-4200
panos_nat_rule:
ip_address: "{{ mgmt_ip }}"
username: ""
password: ""
api_key : "{{ apikey }}"
operation: 'add'
rule_name: "inbound-to-linux-4200"
source_zone: ["internet"]
destination_zone: "internet"
source_ip: ["any"]
destination_ip: ["{{ untrust_ip }}"]
service: "tcp-4200"
snat_type: "dynamic-ip-and-port"
snat_interface: "ethernet1/2"
dnat_address: "{{ linux_ip }}"
dnat_port: "4200"
commit: "False"
- name: inbound-to-linux-22
panos_nat_rule:
ip_address: "{{ mgmt_ip }}"
username: ""
password: ""
api_key : "{{ apikey }}"
operation: 'add'
rule_name: "inbound-to-linux-22"
source_zone: ["internet"]
destination_zone: "internet"
source_ip: ["any"]
destination_ip: ["{{ untrust_ip }}"]
service: "tcp-22"
snat_type: "dynamic-ip-and-port"
snat_interface: "ethernet1/2"
dnat_address: "{{ linux_ip }}"
dnat_port: "22"
commit: "False"
- name: commit
panos_commit:
ip_address: "{{ mgmt_ip }}"
api_key : "{{ apikey }}"
username: ''
password: ''
register: result
until: not result is failed
retries: 1000
delay: 0