交換機部分
兩層和三層交換機清除所有配置的命令
#Set default 清除配置
#Write 保存
#Reload 重啟
交換機打開網站管理 http
兩層 (config)#ip http server
(config)#Web-user xxx password 0-7 xxx
三層 (config)#ip http server 打開http服務
(config)#username xxx privilege 0-7 xxx 新建用戶
(config)#authentication line web login local 驗證
交換機打開telnet ssh
兩層 (config)#telnet-server enable 打開telnet服務
(config)#telnet-user xxx password 0-7 xxx 設置帳號密碼
(config)#ssh-ser-server enable 打開ssh服務
(config)#Ssh-user xxx password 0-7 xxx 設置帳號和密碼
三層 (config)#telnet-server enable
(config)#username xxx privilege 0-7 xxx
(config)#authentication line vty login local
開啟enable密碼
兩層 (config)#enable password xxx 直接開啟enable密碼
端口匯聚
兩層 (config)#port-group 1-32 創建匯聚端口的名字
(Config-If-Port-Range)#port-group 1-32 mode acctive/on/passiv在端口里面選擇主被動
(config-if-port-channel1)#interface port-channel 1 進入組合端口1
(config-if-port-channel1)#switchport mode trunk 設置為trunk
負載分擔
兩層(config)#port-group 1-32 load-balance dst-ip/mac/src-ip/ 選擇方式
三層(config)#load-balance dst-src-ip 分開配置
端口限速
兩層(Config-If-Ethernet1/22)#bandwith control (xxx)K
端口鏡像
兩層config)#monitor session 1-4 destination/source interface ethernet x/x選擇被鏡像的端口和接受的端口
Vlan之間的訪問控制
私有vlan之間的區別
Primary vlan 能被人訪問也能訪問別人,前提是必須綁定需要訪問或者被訪問的vlan
Isolate vlan 互相之間不能訪問,能訪問別人,也能被訪問
Community vlan 能訪問,能互相訪問 但是不能被訪問
(config)#vlan x
(config-vlanx)#private-vlan primary/isolate/connunity 綁定私有vlan
(config-vlanx)#private-vlan association (VLAN) 只有primary需要團體也就是association
Mstp的設置
另外一個交換機在設置mstp時 優先級相反,匯集層交換機需要生成樹,但是不需要綁定優先級
(config)#spanning-tree 打開生成樹
(config)#spanning-tree mst configurtaion 進入mstp生成樹配置
(config-mstp-region)#name xxxx 命名
(config-mstp-region)#instance 0 vlan xx;xx 綁定vlan
(config-mstp-region)#instance 1 vlan xx;xx
(config-mstp-region)#exit
(config)#spanning-tree mst 0 priority 4096 設置這個vlan在交換機的主根
(config)#spanning-tree mst 1 priority 8192 設置這組vlan在交換機的備份根
Vrrp協議的設置
這就是兩條路,一條斷了走另外一條,所以一條要設置成一個vlan的優先路,當優先的斷了,還有一條可以走,下面是優先的設置,優先級改動priority
(config)#vlan 10 創建vlan
(config-vlan10)#switchport interface ethernet 1/1 加入端口
(config-if-vlan10)#ip address 192.168.10.2 255.255.255.0 設置ip
(config-if-vlan10)#exit
(config)#vlan 20
(config-vlan20)#interface vlan 20
Config(-if-vlan20)#ip address 192.168.20.2 255.255.255.0
(config)#router vrrp 10 進入虛擬標識
(config-router)#virtual-ip 192.168.10.254 設置虛擬ip
(config-router)#interface vlan 10 進入vlan10
(config-router)#priority 120 設置優先級
(config-router)#enable 開啟
(config)#router vrrp 20
(config-router)#virtual-ip 192.168.20.254
(config-router)#interface vlan 20
(config-router)#priority 120
(config-router)#enable
Dhcp服務器
switch(config)#vlan 10
switch(config-Vlan10)#ip address 10.1.1.1 255.255.255.0 vlan的地址
switch(config-Vlan10)#exit
switch(config)#vlan 20
switch(config-Vlan20)#ip address 192.168.20.1 255.255.255.0 vlan的地址
switch(config-Vlan20)#exit
switch(config)#service dhcp 開啟dhcp
switch(config)#ip dhcp pool xxx 建立一個地址池
switch(dhcp-xxx-config)#network 10.1.1.1 24 定義地址池內的地址
switch(dhcp-xxx-config)#default-router 10.1.1.1 對應網關
switch(dhcp-xxx-config)#exit
switch(config)#ip dhcp pool lll
switch(dhcp-lll-config)#network 192.168.20.1 24
switch(dhcp-lll-config)#default-router 192.168.20.1
switch(dhcp-lll-config)#exit
(config)#ip dhcp excluded-address 10.1.1.1 10.1.1.10 保留ip
Dhcp中繼服務器
(config)#service dhcp 開啟dhcp
(config)#ip forward-protocol udp bootps 開啟中繼服務
(config)#vlan 10 設置vlan10
(config-if-vlan10)#ip address 10.1.1.2 255.255.255.0 設置vlan10 ip 和 dhcp服務器網段相同
(config)#interface vlan 20 進入vlan20
(config-if-vlan20)#ip address 10.1.2.1 255.255.255.0 定義ip 但是必須和dhcp定義的ip在同一網段
(config-if-vlan20)#ip helper-address 10.1.1.1
Dhcp偵聽,防止干擾
(config)#ip dhcp snooping enable 開啟snooping
(config)#interface ethernet 1/24
(Config-Ethernet1/24)#ip dhcp snooping trust 添加與dhcp服務器相連的端口為信任
端口綁定
snmp服務
(config)#snmp-server community ro public 只讀字符串為pubilc
(config)#snmp-server community rw private 讀寫字符串為private
(config)#snmp-server securityip enable 開啟安全ip模式
(config)#snmp-server securityip xx.xx.xx.xx 設置安全ip
pim-dm方式開啟組播
(config)#ip pim multicast-routing 開啟pim轉發
(config)#ip pim rp-candidate vlan xx 定義組播服務器所在的vlan
(config)#ip pim bsr-candidate vlan xx 候選自舉路由器
(config)#interface vlan xx 進入vlan中
(config-if-vlanxx)#ip pim sparse-mode 開啟組播
(config-if-vlanyy)#ip pim sparse-mode
(config-if-vlanzz)#ip pim sparse-mode
登錄標題
(config)#banner motd biaoti 直接就可以定義標題
超時時間
(config)#exec-timeout 10 直接定義10分鍾
Arp的防范
(config)#interface ethernet 0/1/1
(config-if-ethernet0/1/1)#arp-guard ip 192.168.10.1 綁定網關
(config)#anti-arpscan enable 防ip掃描開啟
(config)#anti-arpscan recovery time 3600 設置自動恢復之間,防止pc發送大量報文
(config-if-ethernet1/0/24)#anti-arpscan trust supertrust-port 設置超級信任端口
Mac地址控制,防止一個主機訪問另外一個主機
(config)#firewall enable 開啟防火牆
(config)#mac-access-list extended xx 設置mac地址訪問表
(config-mac-ext-nacl-mac)#deny host-source-mac 00-FF-51-FD-AE-15 host-destination-mac E0-94-67-05-5D-84 拒絕主機到另外一個主機
(config-mac-ext-nacl-mac)#permit any-source-mac any-destination-mac 允許所有
(config)#int ethernet 0/0/4
(config-if-ethernet0/0/4)#mac access-group xx in 綁定訪問表xx
(config)#int ethernet 0/0/10
config-if-ethernet0/0/10)#switchport port-security 端口安全開啟
(config-if-ethernet0/0/10)#switchport port-security mac-address 44-37-E6-7B-69-AC 綁定安全mac
Acl控制列表 控制端口
(config)#firewall enable 打開防火牆
(config)#ip access-list extended xx 創建訪問控制列表xx
(config-ip-ext-nacl-xx)#deny tcp 0.0.0.0 255.255.255.255 s-p range 6881 6890 host-destination 10.1.1.1 禁止所有網段的端口6881-6890 通過10.1.1.1
(config-ip-ext-nacl-dk)#exit
(config)#interface ethernet 1/0/4
(config-if-ethernet1/0/4)#ip access-group xx in 綁定xx到端口上
生成樹
SW B的配置
(config)#spanning-tree 開啟生成樹
(config)#spanning-tree mode stp 生成樹
(config)#spanning-tree priority 4096 優先級
SW B的配置
#配置STP
(config)#spanning-tree
(config)#spanning-tree mode stp
(config)#spanning-tree priority 8192
SW C的配置
#配置STP
(config)#spanning-tree
(config)#spanning-tree mode stp
設置端口為portfast
(config-if-ethernet1/0/1)#spanning-tree portfast
路由器部分
端口描述
#description xxx 端口描述
配置回環接口
S1_config# interface Loopback0
S1_config_l0# ip address 101.0.0.1 255.255.255.255
S1_config_l0# exit
被動端口
config_f0/0#ip ospf passive
單臂路由
交換機方面將vlan划分好,將連接路由器的端口設置為trunk,然后pc網關為路由器的虛擬網關。
路由器方面:
_Config#interface fastEthernet 0/0 進入與交換機連接的端口
_Config#no shutdown 開啟端口
_Config#interface fastEthernet 0/0.1 進入虛擬端口
_config_f0/0.1#encapsulation dot1Q xx 封裝綁定vlan xx
_config_f0/0.1#ip add 192.168.1.254 255.255.255.0 設置成pc的網關
_Config#interface fastEthernet 0/0.2 進入虛擬端口
_config_f0/0.1#encapsulation dot1Q ll 封裝綁定vlan ll
_config_f0/0.1#ip add 192.168.2.254 255.255.255.0
_Config#interface fastEthernet 0/0.3 進入虛擬端口
_config_f0/0.1#encapsulation dot1Q aa 封裝綁定vlan aa
_config_f0/0.1#ip add 192.168.3.254 255.255.255.0
Enable密碼設置
///////////////////////////////////////////////////////////////////////////////////////////////// 不建議此方法
config#line console 0 進入console0端口
config_line#password 7 123 設置密文密碼
config#aaa authentication login default line 認證登錄
/////////////////////////////////////////////////////////////////////////////////////////////////
aaa authentication enable default enable 開啟telnet 進入enable服務並啟動密碼認證
enable password admin 設置enable密碼
telnet設置Z
///////////////////////////////////////////////////////////////////////////////////////////////// 不建議此方法
config#line vty 0 4 進入端口
config_line#password 0 123 設置明文密碼
config#aaa authentication login default line 認證登錄
/////////////////////////////////////////////////////////////////////////////////////////////////
aaa authentication login default local 開啟telnet 認證為本地
username admin password admin 賬戶密碼
配置邏輯接口
config#interface loopback 0 進入虛擬邏輯端口
config_l0#ip address 192.168.1.1 255.255.255.0 配置地址
config_l0#no shutdown 開啟端口
流量整形
config#policy-map xxx 設置列表xxx
Config-pmap#class yyy 設置class yyy
config_pmap_c#shape average 1000000 bc 2000000 be 100000 平均速率cir為1m bc是突發速率兩兆,最后一個是cir/8 算來的
config#interface fastEthernet 0/0 進入端口
config_f0/0#service-policy output xxx 綁定端口出去的報文為xxx
靜態路由
config#ip route 192.168.1.1 255.255.255.0 10.1.1.2 直接配置下一跳地址
OSPF區域驗證
配置好ospf路由之后
普通驗證:
config#router ospf 1 進入ospf配置模式
config_ospf_1#area 0 authentication simple 使用簡單密碼驗證
config#interface serial 0/2 進入想要驗證的端口
config_s0/2#ip ospf password xxx 設置密碼
然后與之相對的端口相同設置 , 即可通信
Md5驗證:
config#router ospf 1 進去ospf配置模式
config_ospf_1#area 0 authentication message-digest 設置md5登錄
config#interface serial 0/2 進去想要驗證的端口
config_s0/2#ip ospf message-digest-key 1 md5 xxx 設置密碼 那個“1”是指區域ospf1
然后與之對應的另外一個路由器相同設置
Ppp 雙向chap認證
RouteA:
config#username 1 password 1 建立本地用戶
config#interface serial 0/1 進入認證端口
config_s0/1#ip add 1.1.1.1 255.255.255.0 設置ip
config_s0/1#physical-layer speed 64000 母口dce端口設置時間頻率
config_s0/1#encapsulation ppp 開啟認證服務
config_s0/1#ppp authentication chap pap 開啟chap認證
config_s0/1#ppp pap sent-username 2 password 2 設置route2用來驗證
config_s0/1#no shutdown 開啟端口
config#aaa authentication ppp default local 開啟本地驗證
RouteB:
config#username 2 password 2 建立本地用戶
config#interface serial 0/2 進入認證端口
config_s0/1#ip add 1.1.1.2 255.255.255.0 設置ip
config_s0/1#encapsulation ppp 開啟認證服務
config_s0/1#ppp authentication chap pap 開啟chap認證
config_s0/1#ppp pap sent-username 1 password 1 設置route1的帳號密碼驗證
config_s0/1#no shutdown 開啟端口
config#aaa authentication ppp default local 開啟本地驗證
Nat映射
config#interface serial 0/2 進入出口端口
config_s0/2#ip address 10.1.157.250 255.255.255.0 設置ip
config_s0/2#ip nat outside 定義出口nat
config_f0/0#ip add 172.16.1.1 255.255.255.0 進入內網端口,定義ip
config_f0/0#ip nat in 定義內網入口ip
config#ip access-list extended xxx 創建一個nat 內部訪問外部 的 訪問控制列表
config_ext_nacl#permit ip 172.16.1.0 255.255.255.0 any 運行172網段可以訪問出去
config#ip nat pool 1(名字) 10.1.1.1(起始地址) 10.1.1.20(終止地址) 255.255.255.0
config#ip nat inside source sta tcp 172.16.1.3 80 10.1.157.250 80 網站映射(ftp telnet需要該端口)
config#ip nat inside source static 172.16.1.2 10.1.157.78 靜態NAT
config#ip nat inside source list xxx interface serial 0/2 動態NAT 轉端口
config#ip nat translation max-entries host any 100 限制主機內部所有IP NAT 翻譯表項的最大數目為100
config#ip nat inside source list xxx pool 1 overload 動態地址轉換
config#ip route default 10.1.157.77 添加默認路由
Dhcp服務器
config#ip dhcpd enable 打開dhcp服務
config#ip dhcpd pool xxx 設置地址池
config_dhcp#network 10.100.201.254 255.255.255.0 設置網段掩碼
config_dhcp#range 10.100.201.100 10.100.201.200 地址池范圍
config_dhcp#default-router 10.100.203.254 分配網關
config_dhcp#dns-server 8.8.8.8 dns主機地址
config_dhcp#lease 1 租賃時間為一天
IPsec vpn
網絡已經設置好路由,或者在同一網段配置好基本參數
A:
config#ip access-list extended xxx 設置擴展訪問列表名字為xxx
config_ext_nacl#permit ip 192.168.1.0 255.255.255.0 192.168.2.0 255.255.255.0
允許與路由器相連的網關通過
eixt
config#crypto isakmp key 123 10.1.1.2 255.255.255.255 設置加密方法和對面ip
config#crypto isakmp policy 1 優先級為1
config_isakmp#authentication pre-share 共享驗證方法
config_isakmp#encryption 3des 設置加密算法
config_isakmp#hash md5 設置完整性算法為
config_isakmp#group 2 設置小組為2
exit
config#crypto ipsec transform-set yyy 設置集的名字
onfig_crypto_trans#transform-type esp-3des esp-md5-hmac 集合方式為
config_crypto_trans#mode tunnel 隧道模式
config#crypto map zzz 1 ipsec-isakmp 協商模式和crymap名字
config_crypto_map#set transform-set yyy 關聯集
config_crypto_map#set peer 10.1.1.2 設置對面的ip
config_crypto_map#match address xxx 關聯訪問控制列表
exit
int s0/1
config_s0/1#crypto map zzz 綁定vpn crymap
B:
config#ip access-list extended xxx 這是擴展列表名字為xxx
config_ext_nacl#permit ip 192.168.1.0 255.255.255.0 192.168.2.0 255.255.255.0
允許與路由器連接的其它的網段通過
exit
config#crypto isakmp key 123 10.1.1.1 255.255.255.255 對端的密碼和ip
config#crypto isakmp policy 1 優先級為1 與上方一致
config_isakmp#authentication pre-share 共享驗證
config_isakmp#encryption 3des 設置加密算法
config_isakmp#hash md5 完整性算法
config_isakmp#group 2 分組
exit
config#crypto ipsec transform-set yyy 變換集的名字為A的yyy
config_crypto_trans#transform-type esp-3des esp-md5-hmac 集合方式為
config_crypto_trans#mode tunnel 封裝隧道
exit
config#crypto map zzz 1 ipsec-isakmp 與A對應
config_crypto_map#set transform-set yyy 關聯集
config_crypto_map#set peer 10.1.1.1 對端地址
config_crypto_map#match address xxx 關聯訪問控制列表
exit
int s0/2
config_s0/1#crypto map zzz 進入端口中關聯zzz
config#show crypto ipsec sa 查看vpn
Grevpn配置
先保證網絡的正常通信,做好動態或者靜態路由保證網絡的正常運行
然后在:
A:
config#interface tunnel 0 進入虛擬端口0
config_t0#ip address 172.16.1.1 255.255.255.0 配置ip
config_t0#tun source serial 0/2 綁定到物理端口
config_t0#tunnel destination 192.168.1.2 綁定目標地址
config_t0#tunnel key 4 設定密碼為4
B:
config#interface tunnel 0 進入虛擬端口0
config_t0#ip add 172.16.1.2 255.255.255.0
config_t0#tun source serial 0/1 綁定到物理端口
config_t0#tunnel destination 192.168.1.1 綁定目標地址
config_t0#tunnel key 4 設定密碼為4
路由重發布
路由器直連發布
config_rip#redistribute connect
靜態發布
config_rip#redistribute static
Rip和ospf重發布
config#route-map xxx 設置名字為xxx的route-map規則
config_route_map#set metric-type type-2 定義路由類型為E2
config_route_map#match metric 55 定義度量值為55
config_route_map#exit 退出
config#route-map yyy 設置名字為yyy的route-map規則
config_route_map#match metric 2 定義度量值為2
config#router rip 進入rip配置
config_rip#redistribute ospf 1 route-map xxx 將xxx規則綁定在rip的ospf上路由重分布
config#router ospf 1 進去ospf配置
config_ospf_1#redistribute rip route-map yyy 將yyy規則綁定在ospf的rip上路由重分布
時間訪問控制
config#time-range ttt 設置時間訪問控制列表名字為ttt
config_time_range# periodic weekdays 9:00 to 17:00
規則時間為周一到周一到周五九點到五點
config#ip access-list extended kkk 新建一個名字為kkk的非標准列表
config_ext_nacl#permit ip any 10.100.100.0 0.0.0.255 允許任何時間和源地址訪問10.100.100.0的網段
config_ext_nacl#permit ip any 10.100.70.0 0.0.0.255 time-range ttt允許在時間內訪問10.100.70.0的網段
config_s0/1#ip access-group kkk in 在端口上綁定名字為kkk的規則
下發默認路由
Rip
config_rip#redistribute static 轉發默認路由
config_rip#default-information originate 生成默認路由
Ospf
config_ospf_1#default-information originate 生成默認路由
config_ospf_1#default-information originate always總是轉發一條默認路由
DR,BDR 不參與前者的選取
config_s0/2#ip ospf priority 0 優先級為0 不選舉
流量數據優先級別
config#ip access-list extended lll 建立訪問控制列表
config_ext_nacl#permit ip 10.1.1.1 255.255.255.0 10.1.2.1 255.255.255.0
訪問控制列表包含的源地址和目的地址
config#ip access-list extended xxx 建立另外的訪問控制列表
config#permit tcp any any eq telnet 控制telnet流
config_ext_nacl#exit 退出
config#priority-list 1 protocol ip high list lll 指定優先級並且綁定列表
config#priority-list 1 protocol ip low list xxx 綁定兩個控制列表
config_s0/2#priority-group 1 綁定在端口上
Rid
#router ospf 1 進去ospf 進程1
config_ospf_1#router-id 1.1.1.1 設置rid
防火牆
連接防火牆
默認連接端口為eh0 管理ip為192.168.1.1 帳號密碼為admin
Console口連為 交換機的線 頻率為115200
Ac和ap
Ap固定ip
# set management static-ip 1.1.1.5 ip設置
# set management static-mask 255.255.255.0 掩碼設置
重置
#factory-rest 重啟
Ssid(這是ac管理ap,采用的是三層發現)
首先ac要處於管理ap的階段也就是ac要能與apping通,這是簡單的二層接入
(config)#wireless
(config-wireless)#enable 開啟無線管理
(config-wireless)#discovery vlan-list 1 這是ap連接ac連接的端口vlan為1,若想接入其它vlan 必須要把vlan1no掉 因為vlan1自動加入了的
(config-wireless)#ap authentication none 驗證方式為不需要驗證
(config-wireless)#no auto-ip-assign 關閉自動分配ip
(config-wireless)#static-ip 192.168.1.254 配置ac的靜態地址
(config-wireless)#network 1 進入網絡配置模式
(config-network)#ssid dcn-shy 更改ssid
(config-network)#vlan 1 綁定在vlan上
(config-wireless)#ap profile 1 進去ap的配置模式
(config-ap-profile)#hwtype 22 綁定硬件版本 需要對應可以用show ven 查看版本對應的數字
#wireless ap profile apply 1 下發配置
或者
直接在ac里面指定ap的固定ip,如果他有固定ip的話
discovery ip-list xx.xx.xx.xx(IP)
二層發現
#ap database 00-03-0f-19-71-e0
密碼
(config-network)#security mode wpa-personal
(config-network)#wpa key 12345678、
雙ssid
(config-wireless)#network 2 進入網端2
(config-wireless)#ssid ssid-name ssid寫上
(config-wireless)#ap profile 1 進入下發端口1
(config-ap-profile)#radio 1 進入信道1
(config-ap-profile-radio)#vap 1 進去到vap配置模式
(config-ap-profile-vap)#enable 開啟vap1 vap1與network2對應,0與network1對應
然后退出下發即可
隱藏ssid
1
(config-network)#hide-ssid
信道修改
(config-ap-profile-radio)#channel auto
加密
Wpa加密:
(config-network)#security mode wpa-personal 個人加密版
(config-network)#wpa key 12345678 密碼八位數
二層隔離
(config-network)#station-isolation 開啟二層隔離
功率調節
(config-wireless)#ap database 00-03-0f-3c-ca-80 進入ap管理
(config-ap)#radio 1 power 90 輸入百分比功率
Mac黑白名單
(config-wireless)#mac-authentication-mode black-list 添加黑白名單
(config-wireless)#known-client f0-de-f1-f2-8c-cc actio global-action 限制謀個地址策略
(config-wireless)#network 1 進入需要綁定的net口
(config-network)#mac authentication local 綁定mac策略
限速
(config-network)#client-qos bandwidth-limit down 4096 下載帶寬為2M
(config-network)#client-qos bandwidth-limit up 8192 上傳為4M
功率周期調整
(config-wireless)#power-plan mode interval 使之加入規律功率調整
(config-wireless)#power-plan interval 60 一個小時調整一次
#wireless channel-plan bgn start 開啟手工調整
#wireless channel-plan bgn apply 自動調整應
集中轉發與分布轉發
DCWS-6028(config-wireless)#l2tunnel vlan-list 10 //這是集中轉發,填寫用戶 vlan
DCWS-6028(config-wireless)#network 1
DCWS-6028(config-network)#dist-tunnel //這是分布轉發