三层交换基础实验

要求:
1.IP地址基于192.168.1.0/24划分
2.使用OSPF
3.使用DHCP
4.全网可达

三层交换基础实验_第1张图片

1.配置二层交换

SW 3

system-view

[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

SW 4

system-view

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

2.创建虚拟接口配置IP地址

IP规划

需要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

SW1

system-view

[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

三层交换基础实验_第2张图片 

SW2

system-view

[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

三层交换基础实验_第3张图片 3.接口分配VLAN

SW1

[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

三层交换基础实验_第4张图片

 

SW2

[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

三层交换基础实验_第5张图片 

4.配置DHCP

SW1

[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

三层交换基础实验_第6张图片

三层交换基础实验_第7张图片

SW2

[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

三层交换基础实验_第8张图片

三层交换基础实验_第9张图片

5.配置OSPF

SW1

[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

三层交换基础实验_第10张图片 

SW2

[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

三层交换基础实验_第11张图片 

6.测试 

PC1ping其他终端设备

三层交换基础实验_第12张图片

 三层交换基础实验_第13张图片

 三层交换基础实验_第14张图片

 全网可达!!!

 

你可能感兴趣的:(网络)