在一臺三層交換上,通過配置dhcp和路由實現不同VLAN相互通信

本實驗需求:
 通過在cisco catalyst 3550來規劃VLAN 100 和VLAN 200,並且配置DHCP 讓VLAN100人事部計算機獲得IP地址爲192.168.0.0/24,讓VLAN200市場部計算機獲得IP地址爲172.16.0.0/24。因爲市場部和人事部因爲業務上的關係,需要兩臺服務器相互通信,所在還需要在3550上配置VLAN間相互通信。

實驗拓撲:
image
  實驗過程 第一步 配置Catalyst 3550基礎配置
Switch>
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host 3550
3550(config)#no ip do lo
3550(config)#line con 0
3550(config-line)#no exec-t
3550(config-line)#logg syn
3550(config-line)#exit
第二步 在Catalyst 3550 劃分VLAN 100和VLAN 200
//進入全局配置模式下,劃分VLAN(請問catalyst 3500支持在全局模式下劃分VLAN嗎?)
3550(config)#vlan 100
//給VLAN100命名
3550(config-vlan)#name renshibo
3550(config-vlan)#int f0/13
3550(config-if)#switchport mode access
3550(config-if)#switchport access vlan 100
3550(config-if)#spanning-tree portfast
//請問什麼時候需要在交換機接口下配置portfast?這裏如果不配置可以嗎?
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/13 but will only
have effect when the interface is in a non-trunking mode.
3550(config-if)#vlan 200
3550(config-vlan)#name shichangbo
3550(config-vlan)#int f0/15
3550(config-if)#sw mo acc
3550(config-if)#sw acc vlan 200
3550(config-if)#spanning-tree portfast
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/15 but will only
have effect when the interface is in a non-trunking mode.
//驗證VLAN的配置
3550#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/14, Fa0/16, Fa0/17, Fa0/18
Fa0/23, Gi0/1, Gi0/2
100 renshibo active                  Fa0/13
200 shichangbo active              Fa0/15
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
第三步 配置SVI(交換虛擬接口)
3550#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//進入VLAN 100 虛擬接口下
3550(config)#int vlan 100
//增加接口描述,以便將來排錯更加方便
3550(config-if)#description Connection to renshibo
//這裏配置的IP地址就是人事部PC的默認網關地址,如果VLAN接口不配置IP地址,後面的DHCP配置中,PC能否獲得IP地址嗎??
3550(config-if)#ip add 192.168.0.1 255.255.255.0
3550(config-if)#no sh
3550(config-if)#int vlan 200
00:13:22: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan200, changed state to up
3550(config-if)#description Connection to shichangbo
3550(config-if)#ip add 172.16.0.1 255.255.255.0
3550(config-if)#no sh
3550(config-if)#
3550#conf t
//開啓catalyst 3550三層交換路由功能(默認是關閉的)
請問cisco catalyst那些型號交換機是三層交換機?
3550(config)#ip routing
3550(config)#exit
3550#sh ip route
//兩條直連路由條目
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Vlan200
C 192.168.0.0/24 is directly connected, Vlan100
Designated bridge has priority 32768, address ccd1.0a80.0000
Designated port id is 129.65, designated path cost 0
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 993, received 92
第四步 在Catalyst 3550上配置DHCP,以便於VLAN100和VLAN200下客戶端獲得IP地址,掩碼,網關,DNS等
//全局下打開DHCP服務.默認是開啓的嗎?那爲什麼還要需要開啓了?
3550(config)#service dhcp
//關閉dhcp 客戶端IP衝突日誌記錄信息
3550(config)#no ip dhcp conflict logging
//配置地址池名稱,地址池名稱爲任意字符(這裏定義的名字VLAN的名稱)
3550(config)#ip dhcp pool renshibo
//配置PC所獲得網段地址範圍,和掩碼,(這裏有幾種命令語句格式)
(network 192.168.0.0 255.255.255.0)
3550(dhcp-config)#network 192.168.0.0 /24
//配置網關地址
3550(dhcp-config)#default-router 192.168.0.1
//配置DNS(域名解析服務器)可選配置
請問什麼時候PC需要配置DNS地址?局域網通訊需要嗎?
3550(dhcp-config)#dns 218.30.19.40 61.134.1.4
//配置域名
3550(dhcp-config)#domain-name www.cisco.com
//配置地址租期爲永久
3550(dhcp-config)#lease infinite
3550(dhcp-config)#exit
//配置排除的IP地址範圍,不從地址池內分配的地址,不配置排除地址可以嗎?
3550(config)#ip dhcp excluded-address 192.168.0.1
3550(config)#ip dhcp pool shichangbo
3550(dhcp-config)#network 172.16.0.0 /24
3550(dhcp-config)#default-router 172.16.0.1
3550(dhcp-config)#dns 218.30.19.40 61.134.1.4
3550(dhcp-config)#domain-name www.cisco.com
3550(dhcp-config)#lease infinite
3550(dhcp-config)#exit
3550(config)#ip dhcp excluded-address 172.16.0.1
第五步 在市場部PC上驗證是否能從catalyst 3550獲得IP地址, 如圖:開始-運行-cmd-ipconfig /all
image
第六步 在Catalyst 3550查看PC獲得的IP地址是否正確
//查看DHCP綁定信息
3550#sh ip dhcp binding
IP address Client-ID/ (MAC地址) Lease expiration Type
Hardware address
172.16.0.2 0100.16d3.249f.fd Infinite Automatic
192.168.0.2 0100.1641.15e8.5c Infinite Automatic
第七步 在交換機測試是否可以ping通市場部和人事部PC
3550(config)#exit
3550#
00:26:41: %SYS-5-CONFIG_I: Configured from console by console
3550#ping 172.16.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
3550#ping 192.168.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
第八步 在市場部PC上用ping命令測試是否可以ping通VLAN100(人事部) 下PC 如圖:測試結果如下,可以ping通,實驗現象成功!
image
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章