利用思科模擬器配置三層交換機局域網(wǎng)的方法
1. 思科交換機支持的命令:
設置交換機名字為
yzhSwitch 進(jìn)入超級終端控制臺
Switchenable 進(jìn)入交換機特權模式
Switch#Switch#configure terminal 進(jìn)入交換機全局配置模式
Switch(configure)#hostname yzh 改變名字為XXX
交換機基本狀態(tài):
switch: ;ROM狀態(tài), 路由器是rommon
hostname ;用戶(hù)模式
hostname# ;特權模式
hostname(config)# ;全局配置模式
hostname(config-if)# ;接口狀態(tài)
交換機口令設置:
switchenable ;進(jìn)入特權模式
switch#config terminal ;進(jìn)入全局配置模式
switch(config)#hostname ;設置交換機的主機名
switch(config)#enable secret xxx ;設置特權加密口令
switch(config)#enable password xxa ;設置特權非密口令
switch(config)#line console 0 ;進(jìn)入控制臺口
switch(config-line)#line vty 0 4 ;進(jìn)入虛擬終端
switch(config-line)#login ;允許登錄
switch(config-line)#password xx ;設置登錄口令xx
switch#exit ;返回命令
交換機VLAN設置:
switch#vlan database ;進(jìn)入VLAN設置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#no vlan 2 ;刪vlan 2
switch(config)#int f0/1 ;進(jìn)入端口1
switch(config-if)#switchport access vlan 2 ;當前端口加入vlan 2
switch(config-if)#switchport mode trunk ;設置為干線(xiàn)
switch(config-if)#switchport trunk allowed vlan 1,2 ;設置允許的vlan 不明白
switch(config-if)#switchport trunk encap dot1q ;設置vlan 中繼
何為中繼,功能作用,二層到三層設置中繼模式
switch(config)#vtp domain ;設置發(fā)vtp域名 什么是vtp
switch(config)#vtp password ;設置發(fā)vtp密碼
switch(config)#vtp mode server ;設置發(fā)vtp模式
switch(config)#vtp mode client ;設置發(fā)vtp模式
交換機設置IP地址:
switch(config)#interface vlan 1 ;進(jìn)入vlan 1
switch(config-if)#ip address ;設置IP地址
switch(config)#ip default-gateway ;設置默認網(wǎng)關(guān)
switch#dir flash: ;查看閃存
交換機顯示命令:
switch#write ;保存配置信息
switch#show vtp ;查看vtp配置信息
switch#show run ;查看當前配置信息
switch#show vlan ;查看vlan配置信息
switch#show interface ;查看端口信息
switch#show int f0/0 ;查看指定端口信息
2. 思科路由器支持的命令:
路由器顯示命令:
router#show run ;顯示配置信息
router#show interface ;顯示接口信息
router#show ip route ;顯示路由信息
router#show cdp nei ;顯示鄰居信息
router#reload ;重新起動(dòng)
路由器口令設置:
routerenable ;進(jìn)入特權模式
router#config terminal ;進(jìn)入全局配置模式
router(config)#hostname ;設置交換機的主機名
router(config)#enable secret xxx ;設置特權加密口令
router(config)#enable password xxb ;設置特權非密口令
router(config)#line console 0 ;進(jìn)入控制臺口
router(config-line)#line vty 0 4 ;進(jìn)入虛擬終端
router(config-line)#login ;要求口令驗證
router(config-line)#password xx ;設置登錄口令xx
router(config)#(Ctrl+z) ; 返回特權模式
router#exit ;返回命令
路由器配置:
router(config)#int s0/0 ;進(jìn)入Serail接口
router(config-if)#no shutdown ;激活當前接口
router(config-if)#clock rate 64000 ;設置同步時(shí)鐘
router(config-if)#ip address ;設置IP地址
router(config-if)#ip address second ;設置第二個(gè)IP
router(config-if)#int f0/0.1 ;進(jìn)入子接口
router(config-subif.1)#ip address ;設置子接口IP
router(config-subif.1)#encapsulation dot1q ;綁定vlan中繼協(xié)議
router(config)#config-register 0x2142 ;跳過(guò)配置文件
router(config)#config-register 0x2102 ;正常使用配置文件
router#reload ;重新引導
路由器文件操作:
router#copy running-config startup-config ;保存配置
router#copy running-config tftp ;保存配置到tftp
router#copy startup-config tftp ;開(kāi)機配置存到tftp
router#copy tftp flash: ;下傳文件到flash
router#copy tftp startup-config;下載配置文件
ROM狀態(tài):
Ctrl+Break ;進(jìn)入ROM監控狀態(tài)
rommonconfreg 0x2142 ;跳過(guò)配置文件
rommonconfreg 0x2102 ;恢復配置文件
rommonreset ;重新引導
rommoncopy xmodem: flash: ;從console傳輸文件
rommonIP_ADDRESS=10.65.1.2 ;設置路由器IP
rommonIP_SUBNET_MASK=255.255.0.0 ;設置路由器掩碼
rommonTFTP_SERVER=10.65.1.1 ;指定TFTP服務(wù)器IP
rommonTFTP_FILE=c2600.bin ;指定下載的文件
rommontftpdnld ;從tftp下載
rommondir flash: ;查看閃存內容
rommonboot ;引導IOS
靜態(tài)路由:
ip route ;命令格式
router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;靜態(tài)路由舉例
router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;默認路由舉例
動(dòng)態(tài)路由:
router(config)#ip routing ;啟動(dòng)路由轉發(fā)
router(config)#router rip ;啟動(dòng)RIP路由協(xié)議。
router(config-router)#network ;設置發(fā)布路由
router(config-router)#negihbor ;點(diǎn)對點(diǎn)幀中繼用。
幀中繼命令:
router(config)#frame-relay switching ;使能幀中繼交換
router(config-s0)#encapsulation frame-relay ;使能幀中繼
router(config-s0)#fram-relay lmi-type cisco ;設置管理類(lèi)型
router(config-s0)#frame-relay intf-type DCE ;設置為DCE
router(config-s0)#frame-relay dlci 16 ;
router(config-s0)#frame-relay local-dlci 20 ;設置虛電路號
router(config-s0)#frame-relay interface-dlci 16 ;
router(config)#log-adjacency-changes ;記錄鄰接變化
router(config)#int s0/0.1 point-to-point ;設置子接口點(diǎn)對點(diǎn)
router#show frame pvc ;顯示永久虛電路
router#show frame map ;顯示映射
基本訪(fǎng)問(wèn)控制列表:
router(config)#access-list permit|deny
router(config)#interface ;default:deny any
router(config-if)#ip access-group in|out ;default:out
例1:
router(config)#access-list 4 permit 10.8.1.1
router(config)#access-list 4 deny 10.8.1.0 0.0.0.255
router(config)#access-list 4 permit 10.8.0.0 0.0.255.255
router(config)#access-list 4 deny 10.0.0.0 0.255.255.255
router(config)#access-list 4 permit any
router(config)#int f0/0
router(config-if)#ip access-group 4 in
擴展訪(fǎng)問(wèn)控制列表:
access-list permit|deny icmp wild[type]
access-list permit|deny tcp wild[port]
例3:
router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo
router(config)#access-list 101 permit ip any any
router(config)#int s0/0
router(config-if)#ip access-group 101 in
例3:
router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80
router(config)#access-list 102 permit ip any any
router(config)#interface s0/1
router(config-if)#ip access-group 102 out
刪除訪(fǎng)問(wèn)控制例表:
router(config)#no access-list 102
router(config-if)#no ip access-group 101 in
路由器的nat配置
Router(config-if)#ip nat inside ;當前接口指定為內部接口
Router(config-if)#ip nat outside ;當前接口指定為外部接口
Router(config)#ip nat inside source static [p] 私有IP公網(wǎng)IP [port]
Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1
Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80
Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0
Router(config)#ip nat inside source list 1 pool p1
Router(config)#ip nat inside destination list 2 pool p2
Router(config)#ip nat inside source list 2 interface s0/0 overload
Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotary
Router#show ip nat translation
rotary 參數是輪流的意思,地址池中的IP輪流與NAT分配的地址匹配。
overload參數用于PAT 將內部IP映射到一個(gè)公網(wǎng)IP不同的端口上。
外部網(wǎng)關(guān)協(xié)議配置:
routerA(config)#router bgp 100
routerA(config-router)#network 19.0.0.0
routerA(config-router)#neighbor 8.1.1.2 remote-as 200
配置PPP驗證:
RouterA(config)#username password
RouterA(config)#int s0
RouterA(config-if)#ppp authentication {chap|pap}
3.PIX防火墻命令
Pix525(config)#nameif ethernet0 outside security0 ;命名接口和級別
Pix525(config)#interface ethernet0 auto ;設置接口方式
Pix525(config)#interface ethernet1 100full ;設置接口方式
Pix525(config)#interface ethernet1 100full shutdown
Pix525(config)#ip address inside 192.168.0.1 255.255.255.0
Pix525(config)#ip address outside 133.0.0.1 255.255.255.252
Pix525(config)#global (if_name) natid ip-ip ;定義公網(wǎng)IP區間
Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15 ;例句
Pix525(config)#global (outside) 1 133.0.0.1 ;例句
Pix525(config)#no global (outside) 1 133.0.0.1 ;去掉設置
Pix525(config)#nat (if_name) nat_id local_ip [netmark]
Pix525(config)#nat (inside) 1 0 0
內網(wǎng)所有主機(0代表0.0.0.0)可以訪(fǎng)問(wèn)global 1指定的外網(wǎng)。
Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0
內網(wǎng)172.16.5.0/16網(wǎng)段的主機可以訪(fǎng)問(wèn)global 1指定的外網(wǎng)。
Pix525(config)#route if_name 0 0 gateway_ip [metric] ;命令格式
Pix525(config)#route outside 0 0 133.0.0.1 1 ;例句
Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 ;例句
Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8
表示內部ip地址192.168.0.8,訪(fǎng)問(wèn)外部時(shí)被翻譯成133.0.0.1全局地址。
Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8
中間區域ip地址172.16.0.8,訪(fǎng)問(wèn)外部時(shí)被翻譯成133.0.0.1全局地址。
一,配置PC機固態(tài)IP:
雙擊ip configuration
同理配置第二臺電腦,再將這兩臺電腦連接到交換機,這時(shí)候這兩臺電腦就形成了一個(gè)簡(jiǎn)易的局域網(wǎng)了。
如圖:
雙擊這個(gè)按鈕,進(jìn)入電腦的 cmd模式,ping 一下IP
這就表明,這兩臺電腦可以正常的通信了。不過(guò)使用的是廣播模式。
二,配置動(dòng)態(tài)IP
電腦ip configuration選擇DHCP 自動(dòng)獲取IP,然后就需要配置,動(dòng)態(tài)分配IP的服務(wù)器。
雙擊Server的IP configuration,需要給服務(wù)器配個(gè)固態(tài)IP
然后在點(diǎn)擊服務(wù)器的config 中的DHCP 配置動(dòng)態(tài)IP參數
這樣動(dòng)態(tài)IP就分配完了。不過(guò)默認網(wǎng)關(guān)可能載不過(guò)去。這時(shí)需要在電腦上的命令行模式下鍵入,結果如下圖:
加載網(wǎng)關(guān)需要在電腦的命令行下鍵入 ipconfig /renew
這樣固態(tài)IP就配置完成了。
三,配置VLAN三層交換機,連接兩個(gè)局域網(wǎng)
如果一個(gè)局域網(wǎng)要連通,且有不同的局域網(wǎng)就需要劃分vlan,而vlan需要連通就需要三層交換機。
1.在交換機info206劃分出vlan 2 vlan 3 并且把端口劃分進(jìn)vlan,也就是底下的三臺電腦。因為info206有兩個(gè)vlan所以info206連接三層交換機需要使用中繼模式。
2.在三層交換機上劃分出所需的所有vlan ,并給每個(gè)vlan 分配該局域網(wǎng)的網(wǎng)關(guān)為IP。然后就可以連通了。
設置中繼trunk 模式
同樣的在三層交換機上劃分出所有vlan,接下給vlan 配IP(要和該網(wǎng)段的網(wǎng)關(guān)一樣)
然后就搞定了,記住所有的vlan都得配IP。
最后最重要的是開(kāi)戶(hù)三層交換機路由功能 :(全局模式下)ip routing