forked from Sxmon17/cisco_script_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch-template.txt
More file actions
282 lines (217 loc) · 7.32 KB
/
Copy pathswitch-template.txt
File metadata and controls
282 lines (217 loc) · 7.32 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
! ================================================================
! S W I T C H - [DEVICE-NAME]
! ================================================================
! Declare SDM Template
! --------------------
sdm prefer dual-ipv4-and-ipv6 default
! Reload now...
enable
configure terminal
! Set Hostname
! ------------
hostname [HOSTNAME]
! Disable DNL
! -----------
no ip domain-lookup
! Enable Unicast Routing
! ----------------------
ipv6 unicast-routing
! Start Layer 3 Routing
! ---------------------
ip routing
! Set Enable Password
! -------------------
enable secret [ENABLE-PASSWORD]
! Set Console Password
! --------------------
line console 0
motd-banner
logging synchronous
password [CONSOLE-PASSWORD]
exec-timeout [MINUTES (0)] [SECONDS (0)]
login
exit
! Configure Ports For Secure Access
! ---------------------------------
line vty [(PORT-RANGE (0 15)]
motd-banner
logging synchronous
password [PORT-PASSWORD]
exec-timeout [MINUTES (0)] [SECONDS (0)]
transport input [CONNECTION-TYPE (telnet) | (ssh))
login [DB-LOCATION (local)]
exit
! Write Banner MOTD
! -----------------
banner motd [BANNER-MODT (+This is a secure system. Authorized Access Only!+)]
! Create VLAN(s)
! --------------
vlan [VLAN-ID]
name [VLAN-NAME]
exit
! Implement VTP
! -------------
vtp domain [DOMAIN-NAME]
vtp mode [(server) | (client) | (transparent)]
! Activate VTP Server
exit
vtp primary
configure terminal
! Configure Virtual Interface(s)
! ------------------------------
interface vlan [VLAN-ID]
description [VLAN-DESCRIPTION]
ip address [(dhcp)] | [IPv4-ADDRESS] [IPv4-SUBNET-MASK]
ipv6 address [(dhcp)] | [IPv6-ADDRESS/IPv6-PREFIX]
ipv6 address [fe80::LLA-Address] link-local
no shutdown
exit
! Enable RSTP/MST, Portfast And BPDU Guard On All Access Ports
! --------------------------------------------------------
spanning-tree mode [(rapid-pvst) | (mst)]
spanning-tree portfast default
spanning-tree portfast bpduguard default
! Configure Trunk Interface(s), DTP, STP, Trunking, VLANs
! -------------------------------------------------------
interface [(range)] [PORT-TYPE (gig/fa)] [PORT-NUMBER(S) (0/0, 0/1/1, ...)]
description [PORT-DESCRIPTION]
switchport trunk encapsulation dot1q
switchport mode trunk
switchport nonegotiate
switchport trunk native vlan [VLAN-ID]
switchport trunk allowed vlan [VLAN-ID-LIST]
switchport priority extend cos [DEVICE-PRIORITY (1-7)]
mls qos cos [CLASS-OF-SERVICE (1-7)]
mls qos trust [cos | device cisco-phone | dscp | ip-precedence]
spanning-tree [vlan [VLAN-ID]] cost [COST]
spanning-tree [vlan [VLAN-ID]] port-priority [PRIORITY]
mdix auto
speed auto
duplex auto
no shutdown
exit
! Configure Access Interface(s), DTP, STP, Trunking, VLANs
! --------------------------------------------------------
interface [(range)] [PORT-TYPE (gig/fa)] [PORT-NUMBER(S) (0/0, 0/1/1, ...)]
description [PORT-DESCRIPTION]
switchport mode access
switchport nonegotiate
switchport access vlan [VLAN-ID]
switchport voice vlan [VLAN-ID]
switchport priority extend cos [DEVICE-PRIORITY (1-7)]
mls qos cos [CLASS-OF-SERVICE (1-7)]
mls qos trust [cos | device cisco-phone | dscp | ip-precedence]
spanning-tree [vlan [VLAN-ID]] cost [COST]
spanning-tree [vlan [VLAN-ID]] port-priority [PRIORITY]
mdix auto
speed auto
duplex auto
no shutdown
exit
! Adding Security Configurations (not available for all switches)
! ---------------------------------------------------------------
! auto secure
service password-encryption
security passwords min-length [MIN-PASSWORD-LENGTH]
login block-for [TIMOUT-DURATION (180)] attempts [ATTEMPTS (3)] within [TIMESPAN (20)]
! Mitigate ARP & DHCP Attacks
! ---------------------------
ip dhcp snooping
ip dhcp snooping vlan [VLAN-ID]
ip arp inspection vlan [VLAN-ID]
ip arp inspection validate src-mac dst-mac ip
! Configure trusted (infrastructural) links
! -----------------------------------------
interface [(range)] [PORT-TYPE (gig/fa)] [PORT-NUMBER(S) (0/0, 0/1/1, ...)]
ip dhcp snooping trust
ip arp inspection trust
exit
! Mitigate Reconnaisance Attacks
! ------------------------------
no cdp run
no lldp run
! Add Port Security
! -----------------
interface [(range)] [PORT-TYPE (gig/fa)] [PORT-NUMBER(S) (0/0, 0/1/1, ...)]
switchport port-security
switchport port-security maximum [MAX-ADDRESSES (1-132)]
switchport port-security mac-address [STATIC-MAC | sticky]
switchport port-security violation [restict | protect | shutdown]
switchport port-security aging time [MINUTES (10)] | type [absolute | inactivity]
exit
! Create Trunk Links For EtherChannel/LACP/PAgP, Layer 2/3
! --------------------------------------------------------
interface range [PORT-TYPE (gig/fa)] [PORT-NUMBER(S) (0/0, 0/1/1, ...)]
shutdown
no switchport
channel-protocol [lacp | pagp]
channel-group [GROUP-NUMBER (1-6)] mode [active (LACP) | auto (try PAgP) | desirable (PAgP) | on (only EtherChannel) | passive (try LACP)]
no shutdown
exit
interface port-channel [GROUP-NUMBER (1-6]
description [DECRIPTION]
switchport mode trunk
ip address [PORT-IP] [PORT-NETMASK]
ipv6 address [(dhcp)] | [IPv6-ADDRESS/IPv6-PREFIX]
ipv6 address [fe80::LLA-Address] link-local
exit
! Set Load-Balancing Method
! -------------------------
port-channel load-balance [src-dest-mac | src-dest-ip | src-dest-port]
! Create DHCP-Pool(s)
! -------------------
ip dhcp excluded-address [START-IP-ADDRESS] [END-IP-ADDRESS(included)]
ip dhcp pool [POOLNAME]
network [NETWORK-IP-ADDRESS] [NETWORK-IP-SUBNET-MASK]
default-router [IP-ADDRESS]
dns-server [IP-ADDRESS]
domain-name [DOMAIN-NAME(www.example.net)]
lease [LEASE-DURATION(days hours minutes | infinite)]
exit
! Implement General Spanning Tree Settings
! ----------------------------------------
spanning-tree mode rapid-pvst
spanning-tree pathcost method long
spanning-tree vlan [VLAN-ID] priority [PRIORITY]
spanning-tree vlan [VLAN-ID] root [primary | secondary]
spanning-tree vlan [VLAN-ID] hello-time 3
spanning-tree vlan [VLAN-ID] forward-time 10
spanning-tree vlan [VLAN-ID] max-age 20
! Declare Default Gateway
! -----------------------
ip default-gateway [IPv4-DEFAULT-GATEWAY]
ip route 0.0.0.0 0.0.0.0 [IPv4-DEFAULT-GATEWAY]
ipv6 route ::/0 [IPv6-DEFAULT-GATEWAY]
! Disable Unused Services
! -----------------------
! no ip http server
! Configuring SSH-Access
! ----------------------
ip domain-name [DOMAIN-NAME]
username [USERNAME] secret [SSH-PASSWORD]
username [USERNAME] privilege [PRIVILEGE-LEVEL (0-16)]
crypto key generate rsa general-keys modulus [MODULUS-LENGTH (2048)]
ip ssh version 2
! Define ACLs & Device Access
! ---------------------------
! Standard
ip access-list standard [ACL-NUMBER (1-99) | ACL-NAME]
remark [ACL-REMARK]
[SEQ-NUMBER] [deny | permit] [any | host [HOST-IP] | [NETWORK-ADDRESS] [WILDCARD MASK]] [any | host [HOST-IP] | [NETWORK-ADDRESS] [WILDCARD MASK]]
deny any any
exit
! Extended
ip access-list extended [ACL-NUMBER (100-199) | ACL-NAME]
remark [ACL-REMARK]
[SEQ-NUMBER] [deny | permit] [icmp | ip | tcp | udp | ospf] [any | host [HOST-IP] | [NETWORK-ADDRESS] [WILDCARD MASK]] [any | host [HOST-IP] | [NETWORK-ADDRESS] [WILDCARD MASK]] eq [PORT-NUMBER]
deny ip any any
exit
interface [PORT-TYPE (gig/fa)] [PORT-NUMBER (0/0, 0/1/1, ...)]
ip access-group [ACL-NUMBER | ACL-NAME] [in | out]
exit
line vty [(PORT-RANGE(0 15)]
ip access-class [ACL-NAME] [in | out]
exit
! Save Configuration
! ------------------
do write memory