寫在前面
- 問答平臺(tái)看到這樣一個(gè)問題,回答后所以順便整理一下
- 一般情況下,三層交換機(jī)不直接連終端,太浪費(fèi)了,可以連一個(gè)交換機(jī)然后再連終端
傍晚時(shí)分,你坐在屋檐下,看著天慢慢地黑下去,心里寂寞而凄涼,感到自己的生命被剝奪了。當(dāng)時(shí)我是個(gè)年輕人,但我害怕這樣生活下去,衰老下去。在我看來,這是比死亡更可怕的事。--------王小波
案例需求:實(shí)驗(yàn)室有一條接入網(wǎng)線,該網(wǎng)線直接連接PC,PC的IP設(shè)置為 192.168.100.xxx 后可以訪問服務(wù)器機(jī)房的服務(wù)器(IP為192.168.100.1),但是想要實(shí)驗(yàn)室內(nèi)的多臺(tái)PC都能訪問 192.168.100.1,請(qǐng)問交換機(jī)應(yīng)該如何配置?
拓?fù)鋱D設(shè)計(jì)拓?fù)鋱D拓?fù)鋱D。配置 | | 配置三層交換機(jī) | 配置終端IP | ping測(cè)試 |
配置配置三層交換機(jī)在三層交換機(jī)LSW上創(chuàng)建VLANPlease press enter to start cmd line!<Huawei>syst <Huawei>system-view Enter system view, return user view with Ctrl+Z.[Huawei]vlan batch 100 10Info: This operation may take a few seconds. Please wait for a moment...done.[Huawei]Oct 16 2021 14:06:41-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.[Huawei]quit<Huawei>undo terminal debuggingInfo: Current terminal debugging is off.<Huawei>undo terminal monitorInfo: Current terminal monitor is off.<Huawei>undo terminal loggingInfo: Current terminal logging is off.<Huawei>undo terminal trappingInfo: Current terminal trapping is off.
將接口加入到對(duì)應(yīng)VLAN中<Huawei>system-view Enter system view, return user view with Ctrl+Z.[Huawei]interface GigabitEthernet 0/0/1[Huawei-GigabitEthernet0/0/1]port link-type access[Huawei-GigabitEthernet0/0/1]port default vlan 100[Huawei-GigabitEthernet0/0/1]quit[Huawei]port-group 2[Huawei-port-group-2]group-member GigabitEthernet 0/0/2 GigabitEthernet 0/0/3 [Huawei-port-group-2]port link-type access[Huawei-GigabitEthernet0/0/2]port link-type access[Huawei-GigabitEthernet0/0/3]port link-type access[Huawei-port-group-2]port default vlan 10[Huawei-GigabitEthernet0/0/2]port default vlan 10[Huawei-GigabitEthernet0/0/3]port default vlan 10[Huawei-port-group-2]quit
在三層交換機(jī)上給VLAN配置網(wǎng)關(guān)[Huawei]interface Vlanif 100[Huawei-Vlanif100]ip address 192.168.100.254 24[Huawei-Vlanif100]quit[Huawei]interface Vlanif 10[Huawei-Vlanif10]ip address 192.168.10.254 24[Huawei-Vlanif10]quit[Huawei]display ip routing-table | include /24Route Flags: R - relay, D - download to fib------------------------------------------------------------------------------Routing Tables: Public Destinations : 6 Routes : 6 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.10.0/24 Direct 0 0 D 192.168.10.254 Vlanif10 192.168.100.0/24 Direct 0 0 D 192.168.100.254 Vlanif100[Huawei]
配置終端服務(wù)器PC>ipconfigLink local IPv6 address...........: fe80::5689:98ff:fea0:1eb4IPv6 address......................: :: / 128IPv6 gateway......................: ::IPv4 address......................: 192.168.100.1Subnet mask.......................: 255.255.255.0Gateway...........................: 192.168.100.254Physical address..................: 54-89-98-A0-1E-B4DNS server........................:PC>ping 192.168.10.2Ping 192.168.10.2: 32 data bytes, Press Ctrl_C to breakFrom 192.168.10.2: bytes=32 seq=1 ttl=127 time=110 msFrom 192.168.10.2: bytes=32 seq=2 ttl=127 time=47 msFrom 192.168.10.2: bytes=32 seq=3 ttl=127 time=46 ms--- 192.168.10.2 ping statistics --- 3 packet(s) transmitted 3 packet(s) received 0.00% packet loss round-trip min/avg/max = 46/67/110 ms
PC1Welcome to use PC Simulator!PC>ipconfigLink local IPv6 address...........: fe80::5689:98ff:fea7:1ca1IPv6 address......................: :: / 128IPv6 gateway......................: ::IPv4 address......................: 192.168.10.2Subnet mask.......................: 255.255.255.0Gateway...........................: 192.168.10.254Physical address..................: 54-89-98-A7-1C-A1DNS server........................:PC>ping 192.168.100.1Ping 192.168.100.1: 32 data bytes, Press Ctrl_C to breakFrom 192.168.100.1: bytes=32 seq=1 ttl=127 time=47 msFrom 192.168.100.1: bytes=32 seq=2 ttl=127 time=31 ms--- 192.168.100.1 ping statistics --- 2 packet(s) transmitted 2 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/39/47 ms
PC2PC>ipconfigLink local IPv6 address...........: fe80::5689:98ff:fe84:2ce2IPv6 address......................: :: / 128IPv6 gateway......................: ::IPv4 address......................: 192.168.10.3Subnet mask.......................: 255.255.255.0Gateway...........................: 192.168.10.254Physical address..................: 54-89-98-84-2C-E2DNS server........................:PC>ping 192.168.100.1Ping 192.168.100.1: 32 data bytes, Press Ctrl_C to breakRequest timeout!From 192.168.100.1: bytes=32 seq=2 ttl=127 time=47 msFrom 192.168.100.1: bytes=32 seq=3 ttl=127 time=47 msFrom 192.168.100.1: bytes=32 seq=4 ttl=127 time=47 ms--- 192.168.100.1 ping statistics --- 4 packet(s) transmitted 3 packet(s) received 25.00% packet loss round-trip min/avg/max = 0/47/47 ms
一般的解決方案綜合組網(wǎng)案例(更合理地使用三層交換機(jī)):交換機(jī)、三層交換機(jī)、路由構(gòu)建網(wǎng)絡(luò) 需求:實(shí)驗(yàn)室有一條接入網(wǎng)線,該網(wǎng)線直接連接PC,PC的IP設(shè)置為 192.168.4.xxx 后可以訪問服務(wù)器機(jī)房的服務(wù)器(IP為192.168.5.1),但是想要實(shí)驗(yàn)室內(nèi)的多臺(tái)PC都能訪問 192.168.5.1,請(qǐng)問交換機(jī)應(yīng)該如何配置?
綜合組網(wǎng) | 第一步:設(shè)計(jì)好網(wǎng)絡(luò)拓?fù)浣Y(jié)構(gòu);為了緩解三層交換機(jī)的壓力,通常連接外部網(wǎng)路需要連接一個(gè)路由器。路由器的功能要比三成交換機(jī)強(qiáng)大。 | |
- 第二步:在PC1、PC2 和 PC3 及PC4 中配置IP地址,子網(wǎng)掩碼和網(wǎng)關(guān);
PC1: IP地址:192.168.1.1/24 網(wǎng)關(guān):192.168.1.254PC2: IP地址:192.168.2.1/24 網(wǎng)關(guān):192.168.2.254PC3: IP地址:192.168.3.1/24 網(wǎng)關(guān):192.168.3.254PC4: IP地址:192.168.5.1/24 網(wǎng)關(guān):192.168.5.254
- 第三步:在二層交換機(jī) (S3700) LSW1上創(chuàng)建VLAN;
<LSW1>system-view[LSW1]vlan batch 2 to 3 #二層交換機(jī)上創(chuàng)建vlan
- 第四步:將接口加入到交換機(jī) (S3700) LSW1相應(yīng)的vlan中;
[LSW1]interface Ethernet 0/0/2[LSW1-Ethernet0/0/2]port link-type access[LSW1-Ethernet0/0/2]port default vlan 2[LSW1-Ethernet0/0/2]display vlan #查看結(jié)果[LSW1]interface Ethernet 0/0/3[LSW1-Ethernet0/0/3]port link-type access[LSW1-Ethernet0/0/3]port default vlan 3[LSW1-Ethernet0/0/3]display vlan #查看結(jié)果
- 第五步:在二層交換機(jī)LSW1 (S3700) 和三層交換機(jī)LSW2(S5700) 上配置trunk(中繼鏈路)
#在二層交換機(jī)LSW1 (S3700)的Ethernet 0/0/4接口配置trunk[LSW1]interface Ethernet 0/0/4[LSW1-Ethernet0/0/4]port link-type trunk[LSW1-Ethernet0/0/4]port trunk allow-pass vlan all[LSW1-Ethernet0/0/4]quit[LSW1]display current-configuration#在三層交換機(jī)LSW2(S5700)的Ethernet 0/0/4接口配置trunk[LSW2]interface GigabitEthernet 0/0/1[LSW2-GigabitEthernet0/0/1]port link-type trunk[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all[LSW2-GigabitEthernet0/0/1]quit[LSW2]display current-configuration
- 第六步:在三層交換機(jī)LSW2(S5700)上創(chuàng)建vlan,并將接口GE 0/0/2加入到vlan 4中
<LSW2>system-view[LSW2]vlan batch 2 to 4 #三層交換機(jī)上創(chuàng)建vlan[LSW2]interface GigabitEthernet 0/0/2[LSW2-GigabitEthernet0/0/2]port link-type access[LSW2-GigabitEthernet0/0/2]port default vlan 4[LSW2-GigabitEthernet0/0/2]display vlan #查看結(jié)果
- 第七步:在三層交換機(jī) LSW2(S5700) 的虛接口上配置IP
#在vlan 1上配置IP地址[LSW2]interface Vlanif 1[LSW2-Vlanif1]ip address 192.168.1.254 24[LSW2-Vlanif1]quit#在vlan 2上配置IP地址[LSW2]interface Vlanif 2[LSW2-Vlanif2]ip address 192.168.2.254 24[LSW2-Vlanif2]quit#在vlan 3上配置IP地址[LSW2]interface Vlanif 3[LSW2-Vlanif3]ip address 192.168.3.254 24[LSW2-Vlanif3]quit#在vlan 4上配置IP地址[LSW2]interface Vlanif 4[LSW2-Vlanif4]ip address 192.168.4.1 24[LSW2-Vlanif4]quit[LSW2]display ip routing-table | include /24 #查看虛接口配置信息
- 第八步:在路由器AR1(AR2220) 上給接口配置IP地址
<AR1>system-view[AR1]interface GigabitEthernet 0/0/0[AR1-GigabitEthernet0/0/0]ip address 192.168.4.2 24[AR1]interface GigabitEthernet 0/0/1[AR1-GigabitEthernet0/0/1]ip address 192.168.5.254 24 #在路由器上給5.0網(wǎng)段配置網(wǎng)關(guān)[AR1]display ip routing-table | include /24 #查看接口IP地址配置信息
- 第九步:在三層交換機(jī)LSW2(S5700)上配置靜態(tài)路由
<LSW2>system-view[LSW2]ip route-static 192.168.5.0 24 192.168.4.2 #目標(biāo)網(wǎng)段,子網(wǎng)掩碼,下一跳地址[LSW2]display ip routing-table | include /24
- 第十步:在路由器AR1(AR2220) 上配置靜態(tài)路由
<AR1>system-view[AR1]ip route-static 192.168.1.0 24 192.168.4.1 #目標(biāo)網(wǎng)段,子網(wǎng)掩碼,下一跳地址[AR1]ip route-static 192.168.2.0 24 192.168.4.1[AR1]ip route-static 192.168.3.0 24 192.168.4.1[AR1]display ip routing-table | include /24
|