交換機路由器指令
給路由器配置IP位址
Router#:conf t 進入全局模式
Router(config)#int f 端口 進入端口模式
Router(config-if)#:ip address ip+子網路遮罩 配置IP和子網路遮罩
Router(config-if)#:no shutdown 開啟端口
給交換機配置虛拟端口IP位址
Switch#:conf t 進入全局模式
Switch(config)# interface vlan 1 進入虛拟端口
Switch(config-if)# ip address IP+子網路遮罩 配置IP和子網路遮罩
Switch(config-if)# no shutdown 開啟端口
Switch(config)#ip default-gateway 預設網關 給交換機配置預設網關
Switch# show int f(端口) 檢視端口狀态
Switch(config)# hostname 名稱 更改主機名稱
Switch# show version 檢視交換機系統及版本資訊
Switch# show mac-address-table 檢視MAC位址表
Switch(config-if)# duplex {full(全雙工) half(半雙工)auto(自動協商)} 配置接口模式
Switch(config-if)# speed 10/100/1000 auto 配置接口速率
Switch# show arp 檢視ARP快取記錄
Switch# clear arp-cache 清除ARP快取記錄
Switch(config)#:arp ip位址 mac位址 arpa 綁定ARP條目
Router(config)#:ip route 目的網段 子網路遮罩 下一跳路由器的接口IP 配置靜态路由
Router(config)#:ip route 0.0.0.0 0.0.0.0 下一跳路由器的接口IP 配置預設路由
{ 代表任何網絡 }
Router#:show ip route 檢視路由表
#:show running-config 簡寫 sh run 檢視路由(交換)機目前配置資訊
#:show startup-config 簡寫 sh star 檢視路由(交換)機已儲存配置資訊
#:copy running-config startup-config 等效指令 write (wr) 儲存目前配置資訊
#:erase nvram 等效指令:delete {nvram/startup-config} 删除已儲存的配置
配置Console口密碼
(config)#line console 0 進入console 0 端口配置
(config-line)#password 密碼 配置密碼
(config-line)#login 儲存配置
配置進特權密碼
(config)#:enable password 密碼 配置明文密碼
(config)#:enable secret 密碼 配置密文密碼
(config)#:service password-encryption 将所有明文密碼更改成密文密碼
配置遠端管理密碼(必須有特權密碼)
(config)#:line vty o ?(?可以是具體數) 進入終端配置
擴充知識:(config)#:username 裝置使用者名 password 裝置密碼
(config)#:line vty 0 4
(config-line)#:login local (使用裝置使用者名和密碼)
telnet IP 遠端登陸路由(交換)機
TFTP備份路由器鏡像
Router#copy flash tftp
Source filename []? 填寫源IOS鏡像檔案名
address or name of remote host[] ? 填寫FTP伺服器IP位址
Destination filename [源IOS檔案名]? 填寫目标檔案名
TFTP更新或還原路由器鏡像
Router#copy tftp flash
address or name of remote host[] ? 寫FTP伺服器的IP位址
Source filename[]? 填寫FTP伺服器上路由鏡像
Destination filename (IOS檔案名) 确認回車
FTP備份路由器鏡像
Router(config)#:ip ftp username 使用者名 在路由器上配置ftp的使用者名
Router(config)#:ip ftp passwore 密碼 在路由器上配置ftp的用密碼
Router#copy flash ftp 備份IOS
Destination filename [c2600-i-mz.122-28.bin]? 填寫目标檔案名
FTP更新或還原路由器鏡像
Router#copy ftp flash 更新或還原路由器IOS
VLAN基本配置
VLAN資料庫配置模式下建立VLAN
Switch#:vlan database 進入vlan資料庫模式
Switch(vlan)#: vlan (vlan-id) name vlan名稱 建立vlanID 和vlan名稱
Switch(vlan)#:exit 退出和儲存
全局模式下建立VLAN
Switch(config)#:vlan vlan-id 建立vlanID
Switch(config-vlan)#:name 名字 設定vlan名稱
Switch(config)#:no vlan vlan-id 删除vlan
Switch(config-if)#:switchport mode access 定義端口模式
Switch(config-if)#:switchport access vlan-id 将端口配置設定到VLAN中
Switch(config)#:default 端口号 将接口還原到預設配置狀态
Switch#:show vlan brief 檢視VLAN資訊
Switch#:show vlan id vlan-id 檢視某個vlan資訊
Trunk配置
Switch(config)#:interface {FastEthernet GigabitEthernet} slot/port 進入端口
Switch(config-if)#:switchport trunk encapsulation {isl dot1q negotiate} 選擇封裝類型
Switch(config-if)#:switchport mode {dynamic{desirable / auto} trunk} 将接口配置為Trunk
Switch(config-if)#:switchport trunk native vlan vlan-id 指定本真VLAN
Switch(config-if)#:switchport trunk allowed vlan remove vlan-id Trunk中删除VLAN
Switch(config-if)#:switchport trunk allowed vlan add vlan-id Trunk中添加VLAN
Switch#:show interface interface-id switchport 驗證接口模式
以太網通道的配置
Switch(config)#:interface range fastEthernet 0/1-2 進入端口
Switch(config-if-range)#: channel-group 1 mode on 捆綁通道
Switch#:show etherchannel 1 summary 檢視以太網配置
單臂路由的配置 : 将交換機連接配接路由器的端口配置成Trunk模式
Router(config)#:inter f0/0.1 進入路由器子端口
Router(config-subif)#:encapsulation dot1q vlan-id 給子端口封裝VLAN标簽
Router(config-subif)#:ip add ip+子網路遮罩 給子端口配置IP
路由器配置DHCP
Router(config)#:ip dhcp pool pool-name 定義位址池 和位址池名稱
Router(dhcp-config)#: network IP位址段+子網路遮罩 動态配置設定IP位址段
Router(dhcp-config)#: default-router 網管IP 設定網關位址
Router(dhcp-config)#: dns-server DNS位址 為用戶端配置DNS位址
Router(dhcp-config)#: lease 天數 設定位址的租期(機關“天”)
Router(config)#:ip dhcp excluded-address IP IP 預留靜态配置設定的IP位址段或者IP位址
VTP配置
Switch(config)#:vtp domain 名字 建立VTP域
Switch(config)#:vtp mode { server(伺服器模式) client(客戶機模式) transparent(透明模式)} 配置交換機VTP模式
Switch(config)#:vtp password 密碼 配置VTP密碼
Switch(config)#:vtp pruning 配置VTP修剪
Switch(config)#:vtp version 2 配置VTP版本号
Switch#:show vtp password 檢視VTP密碼
Switch#:show vtp status 檢視其他VTP資訊
三層交換
3L-Switch(config) # ip routing 開啟路由功能
3L-Switch# vlan database 進入vlan資料庫模式
3L-Switch#(vlan)#vlan (vlan-id) name vlan名稱 建立vlanID 和vlan名稱
3L-Switch#(vlan)#exit 退出和儲存
3L-Switch(config) #int vlan 2 進入VLAN
3L-Switch(config-if)# ip add 192.168.1.1 255.255.255.0 給VLAN添加IP位址
3L-Switch(config) #int range f0/23 -24 進入和二層交換機連接配接的端口
3L-Switch(config-if-range) #switchport trunk encapsulation dot1q 指定借口封裝方式為802.1q
3L-Switch(config-if-range) #switchport mode trunk 指定借口的模式為Trunk
三層交換配置DHCP中繼 1、進入到VLAN中 配置指令如下
3L-Switch(config-if)#ip helper-address DHCP伺服器的IP
有幾個VLAN就配置幾個VLAN
STP生成樹協定 隻能在交換機上配置
配置PVST+的指令
Switch(config) #spanning-tree vlan 1 開啟生成樹指令
Switch(config) #spanning-tree vlan 1 priority 4096 配置VLAN的網橋優先級
Switch(config) #spanning-tree vlan 1 root primary 指定交換機為VLAN1的根網橋
Switch(config) #spanning-tree vlan 2 root secondary 指定交換機為VLAN2的備網橋
進入端口模式
Switch(config-if) #spanning-tree vlan 1 cost 2-100 更改該端口的端口成本
Switch(config-if) #spanning-tree vlan 1 port-priority 0-128 更改該端口的端口優先級
Switch(config-if) #spanning-tree portfast 将該端口配置成速端口(不參加選舉根端口和指定端口)
HSRP 熱備份路由協定 (在三層交換上要基于VLAN配置,在路由器上要基于路由器端口配置)
1、進入VLAN虛接口端口配置模式下
Switch(config-if) # standby 2 ip 192.168.1.1 (2:組号 192.168.1.1是虛拟路由器的IP位址)
2、配置HSRP的優先級
Switch(config-if) # standby 2 priority 200 (數字越大優先級越高,預設是100)
3、配置HSRP的占先權
Switch(config-if) # standby 2 preempt
4、配置Hello消息的計時器
Switch(config-if) # standby 2 timers 2 8 (預設數字是 3 10) 這條指令可以不用配置
5、配置HSRP的端口跟蹤
Switch(config-if) # standby 2 track f0/1 100 (該端口是連接配接外網路由器的端口,後面的數字是當端口失效時,路由器的熱備份優先級将降低該數值)
标準ACL配置指令:
(允許)(拒絕)
router(config)# access-list 清單号 { permit deny } 源ip或網段 + 反子網路遮罩
(代替反子網路遮罩)
router(config)# access-list 1 permit host 192.168.2.2
(代替所有網絡)
router(config)# access-list 1 deny any
router(config)# no access-list 1 删除标準ACL
将ACL應用于接口
(進) (出)
router(config-if)# ip access-group 清單号 { in out}
擴充ACL
Router(config)# access-list "100-199"{ permit | deny }
(協定) (如果是具體IP可以用host+具體IP不用加子網路遮罩)
protocol 源IP 反子網路遮罩 目标IP 反子網路遮罩
(小于)(大于)(等于)(不等于)
lt gt eq neq 加端口号或者服務
Router(config)# access-list 100 deny any any (拒絕所有)
示例:Router(config)# access-list 100 permit ip 192.168.1.0 0.0.0.255
192.168.2.0 0.0.0.255
删除ACL:Router(config)# no access-list 100 (入口)出口)
将ACL應用到端口 Router(config-if)# ip access-list 100 { in | out }
命名ACL
(标準) (擴充)
Router(config)# ip access-list {standard|extended} 名字
标準命名ACL
Router(config-std-nacl)# { permit | deny }源IP或網段
擴充命名ACL
Router(config-std-nacl)#{permit|deny}{協定}源位址 目标位址 端口号
NAT(網絡位址轉換)
Router# show ip nat translations 檢視目前存在的轉換條目
Router# show ip nat statistics 檢視NAT的統計資訊
靜态NAT (内部端口)(源位址)(靜态轉換)
Router(config)# ip nat inside source static 内部局部位址 内部全局位址
(外部端口)(内部端口)
Router(config-if)# ip nat { outside | inside }
如果要做NAT端口映射 要在内部局部位址前加協定名稱,在後面加端口号 并在整個命名後面
加“ extendable ”
動态NAT
1、在内部和外部端口啟用NAT
2、定義内部網絡中允許通路外部網絡的ACL
指令:Router(config)# access-list 1 permit 源IP網段 反子網路遮罩
3、定義合法内部全局IP位址池
指令:Router(config)# ip nat pool one 起始IP 結束IP netmask 子網路遮罩
4、實作網絡位址轉換
指令:Router(config)# ip nat inside source list 1 pool one
PAT(端口多路複用)
3、定義合法内部全局IP位址池 (起始IP和結束IP相同)
指令:Router(config)# ip nat pool one 起始IP 結束IP netmask 子網路遮罩
指令:Router(config)# ip nat inside source list 1 pool one overload
RIP 動态路由協定(距離矢量)
版本1和版本2的差別:V1版本時廣播 ,宣告路由資訊時不攜帶網絡掩碼
V2版本時多點傳播,宣告路由資訊時攜帶網絡掩碼(可以用于不規則ip位址)
router# show ip rout 查詢路由表
router# show ip protocols 檢視路由協定
RIP v1版本
router(config)# router rip
router(config-router)network + 端口網段
RIP v2版本
router(config-router) version 2 啟動RIP v2版本
router(config-router) no auto-summary 關閉路由彙總功能
router(config-router) network + 端口網段
OSPF 動态路由協定(鍊路狀态)
router# show ip route ospf 隻檢視OSPF學習到的路由
router# show ip protocol 檢視OSPF配置資訊
router# show ip ospf 檢視OSPF的配置
router# show ip ospf database 檢視LSA資料資訊
router# show ip ospf interface 檢視接口上OSPF配置資訊
router# show ip ospf neighbor 檢視鄰居清單及狀态
router# show ip ospf virtual-link 檢視虛鍊路狀态
router(config)# router ospf 1
router(config-router)# rouer-id 配置可以手動選舉DR和BDR (區域号)
router(config-router)# network + 端口網段 +反子網路遮罩 area 0 (代表骨幹區域)
區域邊界路由器(ABR) 自治系統邊界路由器(ASBR)
LSA通告 :LSA1(路由器LSA:Router Link States)
LSA2(網絡LSA:Net Link States)
LSA3(網絡彙總LSA:Summary Net Link States)
LSA4(ASBR彙總LSA:Summary ASB Link States)
LSA5(自治系統外部LSA:Type-5 AS External Link States)
LSA7(NSSA外部LSA:Type-7 AS External Link States)
配置末梢區域和完全末梢區域
router(config-router)# area 1 stub(當配置完全末梢區域時在ABR路由器上後面加:{no-summary})
NSSA 區域配置 : NSSA區域内的所有路由器都需要配置NSSA
router(config-router)# area 1 nssa(當配置NSSA區域時在ABR路由器上後面加:{no-summary})
路由注入配置 (就是配置ASBR路由器)
RIP 和OSPF 之間進行注入指令的示例:
指令是在ASBR路由器上配置
router(config-router)# redistribute rip metric 200 subneta
router(config-router)# redistribute ospf 1 metric 10
在ASBR路由器上注入靜态路由、預設路由、直連路由:
router(config-router)# default-information originate 注入預設路由
router(config-router)# redistribute static subnets 注入靜态路由
router(config-router)# redistribute connected subnets 注入直連路由
OSPF路由協定位址彙總
區域間路由彙總:
router(config-router)# area 1 range 網段+子網
外部路由彙總:
router(config-router)# summary-address 網段+子網
虛鍊路配置 :在将要穿過的區域中的ABR路由器上互相指定對方路由器的loopbac0 配置的IP位址
R1(config-router)# area 1 virtual-link 2.2.2.2
R2(config-router)# area 1 virtual-link 1.1.1.1
使用小凡橋接到VMware 虛拟網卡
1、用真實機 cmd 中輸入“getmac” 檢視網卡的資訊 并把“TCPIP” 更改成NPF
ASA狀态化防火牆基本配置
ciscoasa# show conn detail 檢視Conn表
ciscoasa# show route 檢視路由表
ciscoasa# write memory 儲存配置
ciscoasa# clear configure all 清除未儲存的配置
ciscoasa# clear configure access-list 清除所有ACL
ciscoasa# clear configure access-list 命名 清除單條命名ACL
ciscoasa# write erase 清除已儲存的配置
ciscoasa# show xlate detail 檢視NAT轉換表
ciscoasa# conf t
ciscoasa(config)# hostname ASA 更改主機名
ciscoasa(config)# enable password 111.com 配置特權密碼
ciscoasa(config)# password 222.com 配置遠端登入密碼
接口的安全級别
inside (連接配接内網的端口,安全級别高:100)
outside(連接配接外網的端口,安全級别低: 0 )
dmz (一般用于伺服器釋出,安全級别低于100,高于0)
接口配置指令
ciscoasa(config-if)# nameif {inside/outside/dmz} 要先定義端口的方向
ciscoasa(config-if)# security-level 1-99 配置端口的安全級别
在ASA上配置ACL:1、允許入内網連接配接 2、控制通路外網連接配接的流量 :ASA預設規則禁止入站連接配接
ciscoasa(config)# access-list 命名 { permit/deny } ip host IP host ip 配置ACL
ciscoasa(config)# access-list 命名 { permit/deny } ip ip位址 子網路遮罩 any :禁止子網流量出站
ciscoasa(config)# access-group 命名 in int { inside/outside } 将ACL調用到端口
ASA上配置靜态路由
ciscoasa(config)# route outside ip網段 子網路遮罩 下一跳IP位址
遠端管理ASA
配置Telnet 接入 :預設禁止從外部端口使用,隻允許内網使用
ciscoasa(config)# telnet ip位址或網段+子網路遮罩 inside
ciscoasa(config)# telnet timeout +分鐘 配置連接配接空閑逾時時間
配置SSH接入
ciscoasa(config)# domain-name 域名 配置ASA的域名
ciscoasa(config)# crypto key generate rsa modulus 1024 生成RAS密鑰
ciscoasa(config)# ssh ip網段 +子網路遮罩 inside 允許一個網段接入
ciscoasa(config)# ssh 0 0 inside 允許所有IP接入
ciscoasa(config)# ssh version 2 配置SSH版本為2
PC1# ssh -v 2 -L pix ip位址
ASA應用NAT
動态NAT配置:多位址轉換成多位址
ciscoasa(config)# nat (inside) 1 IP網段+子網路遮罩
ciscoasa(config)# global (outside) 1 全局位址池
ciscoasa(config)# nat (inside) 100 inside區域内所有網段實施動态NAT
動态PAT: 多位址轉換成一個位址
ciscoasa(config)# global (outside) 1 { IP位址 或者 interface }