实验拓扑图
实验需求
- PC1和PC3属于vlan10,PC2和PC4属于vlan20
- vlan10的网关在sw1上,vlan20的网关在sw2上
- 在sw1与sw2上运行OSPF
- 最终实现PC1-4互相通信
实验配置
- PC机配置略
- SW配置
SW1:
[SW1]vlan batch 10 20 12
[SW1]interface GigabitEthernet0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 10[SW1]interface GigabitEthernet0/0/3
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 20[SW1-GigabitEthernet0/0/3]interface GigabitEthernet0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 12[SW1]interface Vlanif 10
[SW1-Vlanif10]ip address 192.168.10.254 24
[SW1]interface Vlanif 12
[SW1-Vlanif12]ip address 192.168.12.1 24[SW1]ospf 1
[SW1-ospf-1]area 0[SW1-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
SW2:
[SW2]vlan batch 10 20 12
[SW2]interface GigabitEthernet0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 10[SW2]interface GigabitEthernet0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]port default vlan 20[SW2-GigabitEthernet0/0/3]interface GigabitEthernet0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 12[SW2]interface Vlanif 10
[SW2-Vlanif10]ip address 192.168.20.254 24
[SW2]interface Vlanif 12
[SW2-Vlanif12]ip address 192.168.12.2 24[SW2]ospf 1
[SW-2ospf-1]area 0[SW2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255