要求:
1.IP地址基于192.168.1.0/24划分
2.使用OSPF
3.使用DHCP
4.全网可达
[Huawei]sysname SW3
[SW3]interface GigabitEthernet 0/0/2
[SW3-GigabitEthernet0/0/2]port link-type access
[SW3-GigabitEthernet0/0/2]port default vlan 2
[SW3-GigabitEthernet0/0/2]quit
[SW3]interface GigabitEthernet 0/0/3
[SW3-GigabitEthernet0/0/3]port link-type access
[SW3-GigabitEthernet0/0/3]port default vlan 3
[SW3-GigabitEthernet0/0/3]quit
[SW3]interface GigabitEthernet 0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 3
Enter system view, return user view with Ctrl+Z.
[Huawei]sy
[Huawei]sysname SW4
[SW4]interface GigabitEthernet 0/0/2
[SW4-GigabitEthernet0/0/2]port link-type access
[SW4-GigabitEthernet0/0/2]port default vlan 20
[SW4-GigabitEthernet0/0/2]quit
[SW4-GigabitEthernet0/0/3]port link-type access
[SW4-GigabitEthernet0/0/3]port default vlan 30
[SW4-GigabitEthernet0/0/3]quit
[SW4-GigabitEthernet0/0/1]port link-type trunk
[SW4-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 to 30
需要5个网段所以一分为8,其他三个预留
VLAN 2 192.168.1.32/27
VLAN 3 192.168.1.64/27
VLAN 4 192.168.1.0/27
VLAN 20 192.168.1.128/27
VLAN 30 192.168.1.196/27
[Huawei]sysname SW1
[SW1]vlan batch 2 3 4
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip address 192.168.1.33 27
[SW1-Vlanif2]quit
[SW1]interface Vlanif 3
[SW1-Vlanif2]ip address 192.168.1.65 27
[SW1-Vlanif3]quit
[SW1]interface Vlanif 4
[SW1-Vlanif4]ip address 192.168.1.1 27
[Huawei]sysname SW2
[SW2]vlan batch 4 20 30
[SW2]interface Vlanif 4
[SW2-Vlanif4]ip address 192.168.1.2 27
[SW2-Vlanif4]quit
[SW2]interface Vlanif 20
[SW2-Vlanif20]ip address 192.168.1.97 27
[SW2]interface Vlanif 30
[SW2-Vlanif30]ip address 192.168.1.129 27
[SW1]interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access 两台三层交换机之间只通过VLAN 4所以用access链路
[SW1-GigabitEthernet0/0/2]port default vlan 4
[SW1-GigabitEthernet0/0/2]quit
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[SW2]interface GigabitEthernet 0/0/1
[SW2-GigabitEthernet0/0/1]port link-type access 两台三层交换机之间只通过VLAN 4所以用access链路
[SW2-GigabitEthernet0/0/1]port default vlan 4
[SW2-GigabitEthernet0/0/1]quit
[SW2]interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2]port link-type trunk
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan 20 30
[SW1]dhcp enable
[SW1]ip pool 1
[SW1-ip-pool-1]network 192.168.1.32 mask 27
[SW1-ip-pool-1]gateway-list 192.168.1.33
[SW1-ip-pool-1]dns-list 114.114.114.0
[SW1-ip-pool-1]quit
[SW1]interface Vlanif 2
[SW1-Vlanif2]dhcp select global
[SW1-Vlanif2]quit
[SW1]ip pool 2
[SW1-ip-pool-2]network 192.168.1.64 mask 27
[SW1-ip-pool-2]gateway-list 192.168.1.65
[[SW1-ip-pool-2]dns-list 114.114.114.0
[SW1-ip-pool-2]quit
[SW1]interface Vlanif 3
[SW1-Vlanif3]dhcp select global
[SW2]dhcp enable
[SW2]ip pool 1
[SW2-ip-pool-1]network 192.168.1.96 mask 27
[SW2-ip-pool-1]gateway-list 192.168.1.97
[SW2-ip-pool-1]dns-list 114.114.114.0
[SW2-ip-pool-1]quit
[SW2]interface Vlanif 20
[SW2-Vlanif20]dhcp select global
[SW2-Vlanif20]quit
[SW2]ip pool 2
[SW2-ip-pool-2]network 192.168.1.128 mask 27
[SW2-ip-pool-2]gateway-list 192.168.1.129
[SW2-ip-pool-2]dns-list 114.114.114.
[SW2-ip-pool-2]quit
[SW2]interface Vlanif 30
[SW2-Vlanif30]dhcp select global
[SW1]ospf 1 router-id 1.1.1.1
[SW1-ospf-1]area 0
[SW1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[SW1-ospf-1-area-0.0.0.0]network 192.168.1.33 0.0.0.0
[SW1-ospf-1-area-0.0.0.0]network 192.168.1.65 0.0.0.0
[SW2]ospf 1 router-id 2.2.2.2
[SW2-ospf-1]area 0
[SW2-ospf-1-area-0.0.0.0]network 192.168.1.2 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]network 192.168.1.97 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]network 192.168.1.129 0.0.0.0
全网可达!!!