一、 概要 掌握思科交換機(jī)和路由器配置,靜態(tài)路由配置,虛擬局域網(wǎng)VLAN 配置,路由器實現(xiàn)Vlan間通信,SSH技術(shù),NAT技術(shù),實現(xiàn)中小型企業(yè)網(wǎng)的網(wǎng)絡(luò)配置,具體需求如下: 1.vlan 10的第一個計算機(jī)地址通過 R2的DHCP服務(wù)器獲得 2.R2上做NAT 3.做靜態(tài)路由,使得所有計算機(jī)可以訪問服務(wù)器,但是R3上不可以寫靜態(tài)路由 4.不同vlan之間計算機(jī)不能訪問 5.所有計算機(jī)不能ping通R2 6.只有vlan 20可以 遠(yuǎn)程SSH R2,其他不行。
二、網(wǎng)絡(luò)拓?fù)鋱D
三、設(shè)計思路 如上圖所示,配置各端口信息。 首先讓所有設(shè)備能夠互相通信,PC0要動態(tài)獲取IP,而與DHCP服務(wù)器又不在同一個局域網(wǎng),因而需要在R1上做DHCP中繼。 R3上不能寫內(nèi)網(wǎng)的靜態(tài)表,因此需要在R2上做NAT,將所有內(nèi)網(wǎng)地址轉(zhuǎn)化到R2 的 F0/1接口上200.100.100.2。 在R1 f0/1上劃分虛擬接口,可以使不同VLAN相互訪問,題目要求不能不同VLAN不能訪問,需要做ACL。 計算機(jī)不能ping通R2,只有VLAN20能SSH訪問R2,通過ACL列表擴(kuò)展,禁止所有地址到R2的ICMP協(xié)議,R2的22端口只對VLAN20開放。
四、核心設(shè)計 1.在交換機(jī)上創(chuàng)建VLAN,并設(shè)置接口模式, 與PC端相連的都是access,其余接口都是trunk模式,這里以S1交換機(jī)為例演示兩種設(shè)置 Switch(config)#vlan 10------------------直接創(chuàng)建vlan 10 Switch(config)#vlan 20------------------直接創(chuàng)建vlan 20
Switch(config)#interface f0/1----------鎖定接口f0/1 Switch(config-if)#switchport mode access---將接口改為接入接口 Switch(config-if)#switchport access vlan 10---將接口化為vlan10
Switch(config)#interface f0/3----------鎖定接口f0/3 Switch(config-if)#switchport mode access---將接口改為接入接口 Switch(config-if)#switchport access vlan 20---將接口化為vlan20
Switch(config)#interface f0/2----------鎖定接口f0/2 Switch(config-if)#switchport mode trunk------將接口改變成trunk接口
2.在R1上劃分虛擬接口,設(shè)置接口地址
Router(config-if)#int f0/1.10-------------------開啟虛擬接口f0/1.10 Router(config-subif)#encapsulation dot1Q 10-----封裝dot1Q,劃進(jìn)vlan10 Router(config-subif)#ip add 192.168.1.230 255.255.255.0----配置網(wǎng)關(guān)地址
Router(config-if)#int f0/1.20-------------------開啟虛擬接口f0/1.20 Router(config-subif)#encapsulation dot1Q 20-----封裝dot1Q,劃進(jìn)vlan10 Router(config-subif)#ip add 192.168.2.230 255.255.255.0----配置網(wǎng)關(guān)地址
Router(config-if)#int f0/1.30-------------------開啟虛擬接口f0/1.10 Router(config-subif)#encapsulation dot1Q 30-----封裝dot1Q,劃進(jìn)vlan30 Router(config-subif)#ip add 192.168.3.230 255.255.255.0----配置網(wǎng)關(guān)地址
3.在R2上做NAT,將三個192網(wǎng)段的以及R1的172網(wǎng)段轉(zhuǎn)化到200.100.100.2上
Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255 Router(config)#access-list 1 permit 192.168.2.0 0.0.0.255 Router(config)#access-list 1 permit 192.168.3.0 0.0.0.255 Router(config)#access-list 1 permit 172.16.1.0 0.0.0.255 Router(config)#ip nat inside source list 1 interface f0/1 overload Router(config)#interface f0/0 Router(config-if)#ip nat inside------------------------定義inside接口 Router(config)#interface f0/1 Router(config-if)#ip nat outside-----------------------定義outside接口
4.簡單配置R3,服務(wù)器地址,服務(wù)器網(wǎng)關(guān)地址為10.1.1.3 要實現(xiàn)ping通服務(wù)器,還需要在R1,R2上做靜態(tài)路由表
R1: Router(config-if)#ip route 200.100.100.0 255.255.255.0 f0/0 Router(config-if)#ip route 10.1.1.0 255.255.255.0 f0/0
R2: Router(config-if)#ip route 192.168.1.0 255.255.255.0 f0/0 Router(config-if)#ip route 192.168.2.0 255.255.255.0 f0/0 Router(config-if)#ip route 192.168.3.0 255.255.255.0 f0/0
---------------這樣整個網(wǎng)絡(luò)基本ping通了,接下來寫DHCP ---------------------------
5.在R2上寫DHCP,由于R2和PC0不在一個局域網(wǎng),需要在R1上做DHCP中繼
R2: Router(config)#ip dhcp pool 0813-------------建立一個dhcp池 Router(dhcp-config)#network 192.168.1.0 255.255.255.0-----規(guī)定地址池網(wǎng)段 Router(dhcp-config)#default-router 192.168.1.230----------默認(rèn)路由器 Router(dhcp-config)#dns-server 8.8.8.8--------------------DNS服務(wù)器地址 Router(dhcp-config)#exit Router(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.32
R1: Router(config)#int f0/1.10 Router(config-subif)#ip helper-address 172.16.1.2--------寫DHCP服務(wù)器的地址
6.不同VLAN不能訪問,在各個虛擬接口上設(shè)置ACL,這里以VLAN10為例 Router(config)#access-list 10 deny 192.168.2.0 0.0.0.255 Router(config)#access-list 10 deny 192.168.3.0 0.0.0.255 Router(config)#access-list 10 permit any Router(config)#int f0/1.10 Router(config-subif)#ip access-group 10 out 7.所有主機(jī)不能ping通R2,即使用ACL擴(kuò)展列表禁止ICMP協(xié)議
R2(config)#access-list 100 deny icmp 192.168.1.0 0.0.0.0 host 172.16.1.2-- --------拒絕192.168.1.0/24 ping 172.16.1.2 R2(config)#access-list 100 deny icmp 192.168.2.0 0.0.0.0 host 172.16.1.2-- --------拒絕192.168.2.0/24 ping 172.16.1.2 R2(config)#access-list 100 deny icmp 192.168.3.0 0.0.0.0 host 172.16.1.2--- --------拒絕192.168.3.0/24 ping 172.16.1.2
R2(config)#int f0/0 R2(config-if)#ip access-group 100 in --------------------進(jìn)方向調(diào)用
8.只有VLAN20能遠(yuǎn)程SSH訪問R2,做法同上
開啟SSH服務(wù) R2(config)#username AAA password 123---------------------設(shè)置本地用戶密碼 R2(config)#ip domain-name xxx ---------------------設(shè)置域名 R2(config)#crypto key generate rsa ---------------------設(shè)置加密秘鑰 The name for the keys will be: R1.xxx Choose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes.
How many bits in the modulus [512]: 1024------------------秘鑰長度 % Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
R1(config)#line vty 0 4 --------------------------------開啟telnet 0 4 *?? 1 1:29:40.893: %SSH-5-ENABLED: SSH 1.99 has been enabled R1(config-line)#login local-------------------------------使用本地賬號密碼登錄 R1(config-line)#transport input ssh-----------------------開啟SSH
設(shè)置ACL R2(config)#access-list 100 permit tcp 192.168.2.0 0.0.0.255 host 172.16.1.2 eq 22---- 允許VLAN20 SSH R2 R2(config)#access-list 100 deny tcp 192.168.1.0 0.0.0.255 host 172.16.1.2 eq 22----拒絕VLAN10 SSH R2 R2(config)#access-list 100 deny tcp 192.168.3.0 0.0.0.255 host 172.16.1.2 eq 22----拒絕VLAN30 SSH R2
R2(config)#access-list 100 permit ip any any
四、實驗截圖 1.Ping通服務(wù)器
2.不能Ping R2 3.同一VLAN可以訪問,不同VLAN不能訪問。
4.DHCP
5.SSH
五、調(diào)試過程中的問題 實驗中遇到的問題:一是單臂路由的設(shè)計使不同網(wǎng)段能夠訪問,而本次的需求是不能訪問,第一個想到的是能不能在交換機(jī)上做ACL,上網(wǎng)查了資料發(fā)現(xiàn)有些交換機(jī)是可以的,但是本次模擬器交換機(jī)做不了,所以只能在R1路由器虛擬接口上做ACL;二是DHCP中繼的問題,這里很清楚服務(wù)器是172.16.1.2,但是在哪個接口上做中繼呢,開始是在int f0/1上,行不通轉(zhuǎn)到int f0/0,還是不行,最后才試到int f0/1.10上面,也弄清了DHCP中繼的原理;最后是做SSH的時候雖然寫了ACL,但是任何主機(jī)都能SSH訪問R2,排查了很久才找到原因,在做所有主機(jī)不能Ping R2的時候,因為ACL最后默認(rèn)deny any,導(dǎo)致不能Ping通服務(wù)器,又加了一條permit ip any any 。而這條規(guī)則順序先于SSH規(guī)則,所以SSH寫的規(guī)則都沒用,刪除這一條,并重新寫到最后一條規(guī)則,SSH訪問控制成功,實驗完成。
|
|
來自: 昵稱63478486 > 《待分類》