HCIA-单臂路由-VLAN-VLAN间通信-OSPF
- 实验拓扑
- 配置步骤
- 第一步 配置二层VLAN
- 第二步 配置VLANIF和IP地址
- 第三步 配置OSPF
- 配置验证
- PC1可以ping通PC2 PC3 PC4
实验拓扑
配置步骤
第一步 配置二层VLAN
第二步 配置VLANIF和IP地址
第三步 配置OSPF
第一步 配置二层VLAN
SW1
sysname SW1
#
undo info-center enable
#
vlan batch 10 20 30 40 200 //一次创建多个vlan
#
interface GigabitEthernet0/0/1 //设置trunk类型,并允许放行的vlan
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 200
#
interface GigabitEthernet0/0/2 //设置access类型
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/4 //设置trunk类型,并允许放行的vlan
port link-type trunk
port trunk pvid vlan 200
port trunk allow-pass vlan 10 20 30 40 200
SW2
sysname SW2
#
undo info-center enable
#
vlan batch 10 20 30 40 200
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 30
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 40
#
interface GigabitEthernet0/0/4
port link-type trunk
port trunk pvid vlan 200
port trunk allow-pass vlan 10 20 30 40 200
第二步 配置VLANIF和IP地址
SW2
interface Vlanif30
ip address 192.168.30.254 255.255.255.0
#
interface Vlanif200
ip address 192.168.200.2 255.255.255.0
#
interface LoopBack0
ip address 192.168.100.2 255.255.255.255
R1
sysname R1
#
interface GigabitEthernet0/0/0.10 //进入子接口
dot1q termination vid 10 //配置dot1q
ip address 192.168.10.254 255.255.255.0
arp broadcast enable //开启ARP广播
#
interface GigabitEthernet0/0/0.20
dot1q termination vid 20
ip address 192.168.20.254 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/0.40
dot1q termination vid 40
ip address 192.168.40.254 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/0.200
dot1q termination vid 200
ip address 192.168.200.1 255.255.255.0
#
interface LoopBack0
ip address 192.168.100.1 255.255.255.255
第三步 配置OSPF
SW2
ospf 100
area 0.0.0.0
network 192.168.100.2 0.0.0.0
network 192.168.30.0 0.0.0.255
network 192.168.200.0 0.0.0.255
R1
ospf 100 //启用OSPF进程100
area 0.0.0.0 //进入区域0
network 192.168.10.0 0.0.0.255 //宣告IP地址
network 192.168.20.0 0.0.0.255
network 192.168.40.0 0.0.0.255
network 192.168.100.1 0.0.0.0
network 192.168.200.0 0.0.0.255
配置验证
PC1可以ping通PC2 PC3 PC4
- 全网互通,其他的均可自行检测