-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildconfig.py
198 lines (189 loc) · 4.6 KB
/
buildconfig.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/env python
import string
import sys
TEAMNUM=sys.argv[1]
def print_beginning():
print """## Last changed: 2016-02-22 09:01:24 UTC
version 15.1X49-D15.4;
system {{
host-name team{0}-firewall;""".format(TEAMNUM)
print """ root-authentication {
encrypted-password "$1$vNKQ4UPn$gyDIaC0/sclRpftu8NhYg/"; ## SECRET-DATA
}
services {
finger;
ftp;
ssh;
telnet;
web-management {
http {
interface [ ge-0/0/1.0 ge-0/0/0.0 ];
}
}
}
syslog {
user * {
any emergency;
}
file messages {
any any;
authorization info;
}
file interactive-commands {
interactive-commands any;
}
}
license {
autoupdate {
url https://ae1.juniper.net/junos/key_retrieval;
}
}
}
security {
screen {
ids-option untrust-screen {
icmp {
ping-death;
}
ip {
source-route-option;
tear-drop;
}
tcp {
syn-flood {
alarm-threshold 1024;
attack-threshold 200;
source-threshold 1024;
destination-threshold 2048;
timeout 20;
}
land;
}
}
}
nat {
static {
rule-set STATIC_NAT {
from zone untrust;"""
def make_nat_rules():
for i in range(1,255):
print """ rule {0} {{
match {{
destination-address 10.3.{1}.{2}/32;
}}
then {{
static-nat {{
prefix {{
172.25.1.{3}/32;
}}
}}
}}
}}""".format(i, TEAMNUM, i, i)
print " }"
def set_proxy_arp():
print """ }
proxy-arp {
interface ge-0/0/0.0 {
address {"""
for i in range(2,255):
print """ 10.3.{0}.{1};""".format(TEAMNUM, i)
def print_security_end():
print """ }
}
}
}
policies {
from-zone trust to-zone trust {
policy default-permit {
match {
source-address any;
destination-address any;
application any;
}
then {
permit;
}
}
}
from-zone trust to-zone untrust {
policy default-permit {
match {
source-address any;
destination-address any;
application any;
}
then {
permit;
}
}
}
from-zone untrust to-zone trust {
policy default-permit {
match {
source-address any;
destination-address any;
application any;
}
then {
permit;
}
}
}
}
zones {
security-zone trust {
tcp-rst;
interfaces {
ge-0/0/1.0 {
host-inbound-traffic {
system-services {
all;
}
}
}
}
}
security-zone untrust {
screen untrust-screen;
interfaces {
ge-0/0/0.0 {
host-inbound-traffic {
system-services {
ping;
}
}
}
}
}
}
}"""
def print_interfaces_and_routing():
print """interfaces {
ge-0/0/0 {
unit 0 {
family inet {"""
print " address 10.3.{0}.1/24;".format(TEAMNUM)
print """ }
}
}
ge-0/0/1 {
unit 0 {
family inet {
address 172.25.1.254/24;
}
}
}
fxp0 {
unit 0;
}
}
routing-options {
static {"""
print " route 0.0.0.0/0 next-hop 10.3.{0}.254;".format(TEAMNUM)
print """ }
}"""
print_beginning()
make_nat_rules()
set_proxy_arp()
print_security_end()
print_interfaces_and_routing()