-
您的位置:
- 網(wǎng)站首頁(yè)
- > 物聯(lián)百科
- > 行業(yè)動(dòng)態(tài)
您的位置:
交換機(jī)在局域網(wǎng)中的應(yīng)用分為兩種:
1、作為二層交換機(jī)使用,為多個(gè)用戶(hù)劃分VLAN,實(shí)現(xiàn)同網(wǎng)段數(shù)據(jù)訪(fǎng)問(wèn)。
2、作為三層交換機(jī)使用,部署用戶(hù)的網(wǎng)關(guān),實(shí)現(xiàn)跨網(wǎng)段數(shù)據(jù)訪(fǎng)問(wèn)
三層交換機(jī)在局域網(wǎng)中的應(yīng)用
要求:用戶(hù)PC1和PC2可以通過(guò)交換機(jī)和路由器訪(fǎng)問(wèn)外部網(wǎng)絡(luò)。
用戶(hù)PC1和PC2的屬于不同的VLAN域。PC1屬于VLAN20,PC2屬于VLAN 30。
PC1的IP地址是20.2.1.2/24,網(wǎng)關(guān)是20.2.1.1/24;PC2的IP地址是30.3.1.3/24 ,網(wǎng)關(guān)是30.3.1.1/24 。
用戶(hù)PC1和PC2的IP地址不是同一網(wǎng)段,且網(wǎng)關(guān)部署在交換機(jī)上。
配置思路
路由器的配置:
子接口配置IP地址和終結(jié)VLAN
IP地址是10.2.1.1/24, 終結(jié)VLAN2
路由器已經(jīng)存在訪(fǎng)問(wèn)用戶(hù)的靜態(tài)路由:
ip route-static 20.2.1.0 255.255.255.0 10.2.1.2
ip route-static 30.3.1.0 255.255.255.0 10.2.1.2
交換機(jī)配置:
第一步:批量創(chuàng)建VLAN 2、VLAN 20和VLAN30
第二步:配置VLANIF接口
第三步:配置連接PC的接口GE0/0/1和GE0/0/2
第四步:配置連接路由器的接口GE0/0/3
第五步:配置缺省路由
說(shuō)明:默認(rèn)路由器的配置已經(jīng)完成,下面只講解交換機(jī)的配置步驟!
配置步驟
第一步:批量創(chuàng)建VLAN 2、VLAN 20和VLAN30
<Switch> system-view
[Switch] vlan batch 2 20 30
第二步:配置VLANIF接口
[Switch] interface Vlanif 2
[Switch-Vlanif2] ip address 10.2.1.2 24
[Switch-Vlanif2] quit
[Switch] interface Vlanif 20
[Switch-Vlanif20] ip address 20.2.1.1 24
[Switch-Vlanif20] quit
[Switch] interface Vlanif 30
[Switch-Vlanif30] ip address 30.3.1.1 24
[Switch-Vlanif30] quit
第三步:配置連接PC的接口GE0/0/1和GE0/0/2
[Switch] interface GigabitEthernet 0/0/1
[Switch-GigabitEthernet0/0/1] port link-type access
[Switch-GigabitEthernet0/0/1] port default vlan 20
[Switch-GigabitEthernet0/0/1] quit
[Switch-GigabitEthernet0/0/2] port link-type access
[Switch-GigabitEthernet0/0/2] port default vlan 30
[Switch-GigabitEthernet0/0/2] quit
第四步:配置連接路由器的接口GE0/0/3
[Switch-GigabitEthernet0/0/3] port link-type trunk
[Switch-GigabitEthernet0/0/3] port trunk allow-pass vlan 2
[Switch-GigabitEthernet0/0/3] quit
第五步:配置缺省路由
[Switch] ip route-static 0.0.0.0 0.0.0.0 10.2.1.1