网络拓扑:
拓扑图
通过ospf实现两个不同网段的三层互通二层隔离
The device is running!
<Huawei>system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname Switch #修改设备名称
[Switch A]vlan batch 10 30 #批量创建vlan10 30
[Switch A]interface GigabitEthe.NET 0/0/1 #进入端口0/0/1
[Switch A-GigabitEthernet0/0/1]port link-type trunk #配置端口类型为trunk
[Switch A-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 #配置端口允许vlan 10
[Switch A-GigabitEthernet0/0/1]quit #退出端口
[Switch A]interface GigabitEthernet 0/0/2 #进入端口0/0/2
[Switch A-GigabitEthernet0/0/2]port link-type trunk #配置端口类型为trunk
[Switch A-GigabitEthernet0/0/2]port trunk allow-pass vlan 30 #配置端口允许vlan 30
[Switch A-GigabitEthernet0/0/2]quit #退出端口
[Switch A]interface Vlanif 10 #进入vlanif 10
[Switch A-Vlanif10]ip address 10.10.10.1 24 #配置IP地址及子网掩码
[Switch A-Vlanif10]quit #退出
[Switch A]interface Vlanif 30 #进入vlanif 30
[Switch A-Vlanif30]ip address 10.10.30.1 24 #配置IP地址及子网掩码
[Switch A-Vlanif30]quit #退出
[Switch A]interface LoopBack 0 #进入looback 0接口
[Switch A-LoopBack0]ip address 1.1.1.1 32 #配置IP地址及子网掩码
[Switch A-LoopBack0]quit #对此
[Switch A]ospf 1 #创建编号为1的ospf
[Switch A-ospf-1]area 0 #进入area 0 区域
[Switch A-ospf-1-area-0.0.0.0]network 10.10.10.0 0.0.0.255 #宣告网络及网络长度
[Switch A-ospf-1-area-0.0.0.0]network 10.10.30.0 0.0.0.255 #宣告网络及网络长度
[Switch A-ospf-1-area-0.0.0.0]quit #退出区域0
[Switch A-ospf-1]quit #退出ospf 1
The device is running!
<Huawei>system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname Switch B #修改设备名称
[Switch B]vlan batch 10 30 #批量创建vlan 10 30
[Switch B]interface GigabitEthernet 0/0/1 #进入端口0/0/1
[Switch B-GigabitEthernet0/0/1]port link-type trunk #配置端口类型为trunk
[Switch B-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 #配置端口允许vlan 10
[Switch B-GigabitEthernet0/0/1]quit #退出端口
[Switch B]interface GigabitEthernet 0/0/2 #进入端口0/0/2
[Switch B-GigabitEthernet0/0/2]port link-type trunk #配置端口类型为trunk
[Switch B-GigabitEthernet0/0/2]port trunk allow-pass vlan 30 #配置端口允许vlan 30
[Switch B-GigabitEthernet0/0/2]quit #退出端口
[Switch B]interface Vlanif 10 #进入vlanif 10
[Switch B-Vlanif10]ip address 10.10.20.1 24 #配置IP地址及子网掩码
[Switch B-Vlanif10]quit #退出
[Switch B]interface Vlanif 30 #进入vlanif 30
[Switch B-Vlanif30]ip address 10.10.30.2 24 #配置IP地址及子网掩码
[Switch B-Vlanif30]ping 10.10.30.1 #检测与交换机A的是否连通
PING 10.10.30.1: 56 data bytes, press CTRL_C to break
Reply from 10.10.30.1: bytes=56 Sequence=1 ttl=255 time=80 ms
Reply from 10.10.30.1: bytes=56 Sequence=2 ttl=255 time=1 ms
Reply from 10.10.30.1: bytes=56 Sequence=3 ttl=255 time=50 ms
Reply from 10.10.30.1: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 10.10.30.1: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 10.10.30.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/40/80 ms
[Switch B-Vlanif30]quit #退出
[Switch B]interface LoopBack 0 #进入looback 0接口
[Switch B-LoopBack0]ip address 2.2.2.2 32 #配置IP地址及子网掩码,用做router ID
[Switch B-LoopBack0]quit #退出
[Switch B]ospf 1 #创建编号为1的ospf #同样创建ospf 编号为1
[Switch B-ospf-1]area 0 #area区域为0,主干区域
[Switch B-ospf-1-area-0.0.0.0]network 10.10.20.0 0.0.0.255 #宣告网络及网络长度
[Switch B-ospf-1-area-0.0.0.0]network 10.10.30.0 0.0.0.255 #宣告网络及网络长度
[Switch B-ospf-1-area-0.0.0.0]quit #退出
[Switch B-ospf-1]quit #退出
The device is running!
<Huawei>system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname Switch C #修改设备名称
[Switch C]vlan 10 #创建vlan 10
[Switch C]interface GigabitEthernet 0/0/2 #进入端口0/0/2
[Switch C-GigabitEthernet0/0/2]port link-type access #配置端口类型
[Switch C-GigabitEthernet0/0/2]port default vlan 10 #配置默认vlan为10
[Switch C-GigabitEthernet0/0/2]quit #退出
[Switch C]interface GigabitEthernet 0/0/1 #进入端口0/0/1
[Switch C-GigabitEthernet0/0/1]port link-type trunk #配置端口类型
[Switch C-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 #配置允许通行的vlan为10
[Switch C-GigabitEthernet0/0/1]quit #退出
The device is running!
<Huawei>system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname Switch D #修改设备名称
[Switch D]vlan 10 #创建vlan 10
[Switch D]interface GigabitEthernet 0/0/2 #进入端口0/0/2
[Switch D-GigabitEthernet0/0/2]port link-type access #配置端口类型
[Switch D-GigabitEthernet0/0/2]port default vlan 10 #配置端口默认vlan为10
[Switch D-GigabitEthernet0/0/2]quit #退出
[Switch D]interface GigabitEthernet 0/0/1 #进入端口0/0/1
[Switch D-GigabitEthernet0/0/1]port link-type trunk #配置端口类型
[Switch D-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 #配置允许通行的vlan为10
[Switch D-GigabitEthernet0/0/1]quit #退出
查看PC1 ip地址及测试可以访问10.10.20.0的网段
检测pc2连通性和路由
查看PC2 ip地址及测试可以访问10.10.10.0的网段
检测pc1连通性和路由