1 VLAN间通信之单臂路由
1.1 问题
1)如图配置PC和路由器的接口IP地址
2)在R1上配置单臂路由,实现 PC1/2 之间的互通
1.2 方案
使用eNSP搭建实验环境,如图-1所示。
1.3 步骤
[hidecontent type=”payshow”]
实现此案例需要按照如下步骤进行。
步骤一:配置交换机
- [SW1]vlan batch 10 20
- [SW1]interface eth0/0/1
- [SW1–Ethernet0/0/1]port link–type access
- [SW1–Ethernet0/0/1]port default vlan 10
- [SW1]interface eth0/0/2
- [SW1–Ethernet0/0/2]port link–type access
- [SW1–Ethernet0/0/2]port default vlan 20
- [SW1]interface g0/0/1
- [Huawei–GigabitEthernet0/0/1]port link–type trunk
- [Huawei–GigabitEthernet0/0/1]port trunk allow–pass vlan 10 20
步骤二:配置路由器
- [R1]interface g0/0/1.1
- [R1–GigabitEthernet0/0/1.1]dot1q termination vid 10
- [R1–GigabitEthernet0/0/1.1]ip address 10.10.0.1 24
- [R1–GigabitEthernet0/0/1.1]arp broadcast enable
- [R1–GigabitEthernet0/0/1.1]interface g0/0/1.2
- [R1–GigabitEthernet0/0/1.2]dot1q termination vid 20
- [R1–GigabitEthernet0/0/1.2]ip address 10.20.0.1 24
- [R1–GigabitEthernet0/0/1.2]arp broadcast enable
步骤三:测试
使用ping命令测试,如图-2所示。
2 VLAN间通信之三层交换机
2.1 问题
1)如图配置PC的IP地址
2)将SW3配置为每个VLAN的网关
3)实现不同PC之间的互通
2.2 方案
使用eNSP搭建实验环境,如图-3所示。
2.3 步骤
实现此案例需要按照如下步骤进行。
1)在SW1/2/3配置vlan的相关配置
- [SW1]vlan batch 1 2 3 4 5
- [SW1]interface Ethernet0/0/1
- [SW1–Ethernet0/0/1]port link–type access
- [SW1–Ethernet0/0/1]port default vlan 1
- [SW1]interface Ethernet0/0/2
- [SW1–Ethernet0/0/2]port link–type access
- [SW1–Ethernet0/0/2]port default vlan2
- [SW1]interface Ethernet0/0/3
- [SW1–Ethernet0/0/3]port link–type access
- [SW1–Ethernet0/0/3]port default vlan3
- [SW1]interface g0/0/1
- [SW1–GigabitEthernet0/0/1]port link–type trunk
- [SW1–GigabitEthernet0/0/1]port trunk allow–pass vlan all
- [SW2]vlan batch 1 2 3 4 5
- [SW2]interface Ethernet0/0/4
- [SW2–Ethernet0/0/4]port link–type access
- [SW2–Ethernet0/0/4]port default vlan4
- [SW2]interface Ethernet0/0/5
- [SW2–Ethernet0/0/5]port link–type access
- [SW2–Ethernet0/0/5]port default vlan5
- [SW2]interface g0/0/2
- [SW2–GigabitEthernet0/0/2]port link–type trunk
- [SW2–GigabitEthernet0/0/2]port trunk allow–pass vlan all
- [SW3]vlan batch 1 2 3 4 5
- [SW3]interface g0/0/1
- [SW3–GigabitEthernet0/0/1]port link–type trunk
- [SW3–GigabitEthernet0/0/1]port trunk allow–pass vlan all
- [SW3]interface g0/0/2
- [SW3–GigabitEthernet0/0/2]port link–type trunk
- [SW3–GigabitEthernet0/0/2]port trunk allow–pass vlan all
2)配置三层交换机 SW3 的 vlanif 接口
- [SW3]int Vlanif 1
- [SW3–Vlanif1]ip add 192.168.1.254 24
- [SW3–Vlanif1]quit
- [SW3]int Vlanif 2
- [SW3–Vlanif2]ip add 192.168.2.254 24
- [SW3–Vlanif2]quit
- [SW3]int Vlanif 3
- [SW3–Vlanif3]ip add 192.168.3.254 24
- [SW3–Vlanif3]quit
- [SW3]int Vlanif4
- [SW3–Vlanif4]ip add 192.168.4.254 24
- [SW3–Vlanif4]quit
- [SW3]int Vlanif5
- [SW3–Vlanif5]ip add 192.168.5.254 24
- [SW3–Vlanif5]quit
3)配置PC的IP地址,并测试PC间的互通性
3 VLANIF 案例实践
3.1 问题
1)不同的VLAN属于不同的网段,如 192.168.x.0/24(X为 vlan 号)
2)VLAN 中的主机IP地址为 192.168.X.Y/24,网关为 192.168.x.254/24(Y是主机的号码)
3)根据实际需求,添加额外的网段,实现不同VLAN之间的设备互通
3.2 方案
使用eNSP搭建实验环境,如图-4所示。
3.3 步骤
实现此案例需要按照如下步骤进行。
1)如图配置PC的IP地址和网关
2)配置交换机的基本信息(SW1/2/3/4/5都配置)
- 创建 vlan 10\20\30\40
- 交换机之间的链路都配置为Trunk,并允许所有的VLAN
- 交换机与PC之间的链路配置为Access,并加入到正确的VLAN
3)在三层交换机上配置每个VLAN的网关接口和路由,实现不同网段互通
- SW1:
- interface vlanif 10
- ip address 192.168.10.254 24
- quit
- vlan 12
- quit
- interface vlanif 12
- ip address 192.168.12.1 24
- quit
- ip route–static 192.168.20.0 24 192.168.12.2
- ip route–static 192.168.30.0 24 192.168.12.2
- ip route–static 192.168.40.0 24 192.168.12.2
- SW2:
- interface vlanif 20
- ip address 192.168.20.254
- quit
- vlan 12
- quit
- interface vlanif 12
- ip address 192.168.12.2 24
- quit
- ip route–static 192.168.10.0 24 192.168.12.1
- vlan 23
- quit
- interface vlanif 23
- ip address 192.168.23.2 24
- quit
- ip route–static 192.168.30.0 24 192.168.23.3
- ip route–static 192.168.40.0 24 192.168.23.3
- SW3:
- interface vlanif 30
- ip address 192.168.30.254 24
- quit
- interface vlanif 40
- ip address 192.168.40.254 24
- quit
- vlan 23
- quit
- interface vlanif 23
- ip address 192.168.23.3 24
- quit
- ip route–static 192.168.10.0 24 192.168.23.2
- ip route–static 192.168.20.0 24 192.168.23.2
4)测试PC间互通
4 配置默认路由
4.1 问题
配置设备的接口IP地址,并通过配置静态路由和默认路由,实现全网设备互通
4.2 方案
使用eNSP搭建实验环境,如图-5所示。
4.3 步骤
实现此案例需要按照如下步骤进行。
1)配置PC的IP地址和网关
2)保持交换机SW1/2的默认配置不变
3)配置R1/R2/R3的接口IP地址
4)配置R1/R2/R3的路由条目
- [R1] ip route–static 0.0.0.0 0 192.168.2.2
- [R2] ip route–static 192.168.1.0 24 192.168.2.1
- [R2] ip route–static 192.168.4.0 24 192.168.3.2
- [R3] ip route–static 0.0.0.0 0 192.168.3.1
5)测试PC1和PC2之间的连通性
5 路由网综合案例
5.1 问题
1)如图配置不同PC的IP地址和网关
2)每个VLAN的IP地址为 192.168.XX.0/24(XX为vlan 号)
3)每个 VLAN内的主机的网关IP地址为 192.168.XX.254,XX为 vlan 号
4)确保不同网段的PC是可以互通的
5.2 方案
使用eNSP搭建实验环境,如图-6所示。
5.3 步骤
实现此案例需要按照如下步骤进行。
1)配置PC的IP地址和网关
2) 配置SW1/5/6的vlan为10/20/30,交换机之间的链路为Trunk,与PC间为Access
3)配置SW2/3/7的vlan为40/50,交换机之间的链路为Trunk,与PC间为Access
4) 配置SW4/8/9的vlan为60/70/80,交换机之间的链路为Trunk,与PC间为Access
5)配置R1/R2/R3的接口IP地址
6)配置每个 VLAN 的网关接口IP地址
- SW1为vlan10/20/30的网关设备:
- interface vlanif 10
- ip address 192.168.10.254 24
- quit
- interface vlanif 20
- ip address 192.168.20.254 24
- quit
- interface vlanif 30
- ip address 192.168.30.254 24
- quit
- SW2为 vlan 40 的网关:
- interface vlanif 40
- ip address 192.168.40.254 24
- quit
- SW3为 vlan 50 的网关:
- interface vlanif 50
- ip address 192.168.50.254 24
- quit
- R3的 gi0/0/0为 vlan60/70/80 的网关:
- interface gi0/0/0.60
- dot1q termination vid 60
- arp broadcast enable
- ip address 1921.68.60.254 24
- quit
- interface gi0/0/0.70
- dot1q termination vid 70
- arp broadcast enable
- ip address 1921.68.70.254 24
- quit
- interface gi0/0/0.80
- dot1q termination vid 80
- arp broadcast enable
- ip address 1921.68.80.254 24
- quit
7)在SW1与R1之间添加 vlan 100,实现两者互通
- SW1:
- vlan 100
- quit
- interface gi0/0/1
- port link–type access
- port default vlan 100
- quit
- interface vlanif 100
- ip address 192.168.100.100 24
- quit
- ip route–static 0.0.0.0 0 192.168.100.1
- R1:
- interface gi0/0/0
- ip address 192.168.100.1 24
- quit
- ip route–static 192.168.10.0 24 192.168.100.100
- ip route–static 192.168.20.0 24 192.168.100.100
- ip route–static 192.168.30.0 24 192.168.100.100
- ip route–static 192.168.40.0 24 192.168.12.2
- ip route–static 192.168.50.0 24 192.168.12.2
- ip route–static 192.168.60.0 24 192.168.12.2
- ip route–static 192.168.70.0 24 192.168.12.2
- ip route–static 192.168.80.0 24 192.168.12.2
8)在SW2与R2之间添加 vlan 400,实现两者互通
- SW2:
- vlan 400
- quit
- interface gi0/0/1
- port link–type access
- port default vlan 400
- quit
- interface vlanif 400
- ip address 192.168.200.3 24
- quit
- ip route–static 0.0.0.0 0 192.168.200.2
- R2:
- interface gi0/0/0
- ip address 192.168.200.2 24
- quit
- ip route–static 192.168.40.0 24 192.168.200.3
9)在SW3与R2之间添加 vlan 500,实现两者互通
- SW3:
- vlan 500
- quit
- interface gi0/0/1
- port link–type access
- port default vlan 500
- quit
- interface vlanif 500
- ip address 192.168.255.3 24
- quit
- ip route–static 0.0.0.0 0 192.168.255.2
- R2:
- interface gi4/0/0
- ip address 192.168.255.2 24
- quit
- ip route–static 192.168.50.0 24 192.168.255.3
- ip route–static 192.168.10.0 24 192.168.12.1
- ip route–static 192.168.20.0 24 192.168.12.1
- ip route–static 192.168.30.0 24 192.168.12.1
- ip route–static 192.168.60.0 24 192.168.23.3
- ip route–static 192.168.70.0 24 192.168.23.3
- ip route–static 192.168.80.0 24 192.168.23.3
10)在R3上配置路由条目信息,实现与其他PC所在的网段的互通
- ip route–static 192.168.10.0 24 192.168.23.2
- ip route–static 192.168.20.0 24 192.168.23.2
- ip route–static 192.168.30.0 24 192.168.23.2
- ip route–static 192.168.40.0 24 192.168.23.2
- ip route–static 192.168.50.0 24 192.168.23.2
- ip route–static 192.168.60.0 24 192.168.23.2
11)测试不同网段的PC之间的连通性
[/hidecontent]