网络工程师Day1--实验1-4 配置三层交换


学习目标

掌握通过三层交换机实现VLAN间通信的配置方法

掌握通过以太网Trunk链路实现VLAN间通信的配置方法

掌握在不同VLAN间配置动态路由协议OSPF的方法

拓扑图

网络工程师Day1--实验1-4 配置三层交换_链路

场景

在企业网络中,通过使用三层交换机可以简便的实现VLAN间通信。作为企业的网络管理员,您需要在三层交换机配置VLANIF接口的三层功能,使得如上所示拓扑图中的网络能够实现VLAN间通信。此外,为了使S1和S2所连接的网络能够进行三层通信,还需要配置路由协议。

理想的实验效果

以R1为例,可以通过S1ping通S3:10.0.3.3.

网络工程师Day1--实验1-4 配置三层交换_ip地址_02

在配置OSPF前无法ping通R3:10.0.6.3

的配置OSPF后可以ping通R3:10.0.6.3

网络工程师Day1--实验1-4 配置三层交换_链路_03

操作步骤

1 实验环境的准备

1.1 对S1进行配置

system-view

sysname s1

interface Eth-Trunk 1

mode lacp-static

port link-type trunk

port trunk allow-pass vlan all

quit

interface gi 0/0/1

eth-trunk 1

interface gi 0/0/2

eth-trunk 1

quit

1.2 对S2进行配置

system-view

sysname s1

interface Eth-Trunk 1

mode lacp-static

port link-type trunk

port trunk allow-pass vlan all

quit

interface gi 0/0/1

eth-trunk 1

interface gi 0/0/2

eth-trunk 1

quit

1.3 对S3进行配置

sysname S3

interface gi 0/0/1

1.4 对S4进行配置

sysname S4

interface gi 0/0/1

1.5 对R1进行配置

sysname R1

interface e 0/0/0

ip address 10.0.4.1 24

1.6 对R3进行配置

sysname R3

interface e0/0/0

ip address 10.0.6.3 24

2 在S1和S2上批量创建VLAN3到VLAN7

vlan batch 3 to 7//在S1上批量创建VLAN3到VLAN7

vlan batch 3 to 7//在S2上批量创建VLAN3到VLAN7

确认VLANA已经成功创建

display vlan

3 配置Eth-Trunk链路

将S1的gi0/0/3,gi0/0/4端口分别加入VLAN3和VLAN4.

将S2的gi0/0/3,gi0/0/4端口分别加入VLAN3和VLAN4.

将VLAN5作为虚拟的路由,通过VLAN5进行trunk。

s1

interface Eth-Trunk 1

port trunk pvid vlan 5

quit

interface gi 0/0/3

port link-type access

port default vlan 3

quit

interface gi 0/0/4

port link-type access

port default vlan 4

quit

s2

interface Eth-Trunk 1

port trunk pvid vlan 5

quit

interface gi 0/0/3

port link-type access

port default vlan 6

quit

interface gi 0/0/4

port link-type access

port default vlan 7

quit

确定vlan以及成员信息

display vlan

4 配置VLANIF三层接口

分别为S1上的VLANIF3,VLANIF4,VLANIF5,S2上的VLANIF5,VLANIF6,VLANIF7配置IP地址

S1

interface vlanif 3

ip address 10.0.3.254 24

interface vlanif 4

ip address 10.0.4.254 24

interface vlanif 5

ip address 10.0.5.1 24

S2

interface vlanif 5

ip address 10.0.5.2 24

interface vlanif 6

ip address 10.0.6.254 24

interface vlanif 7

ip address 10.0.7.254 24

5 为R1,R3,S3,S4配置IP地址和缺省路由

本实验中,R1,R3,S3,S4模拟客户端主机,四台设备都需要配置一个用户IP地址,其中S3和S4使用VLANIF1接口配置IP地址,然后将S3的G0/0/1接口和S4的G0/0/1接口加入到VLAN1中,R1的地址应该配置为10.0.4.1 24.最后为每台设备配置一条缺省静态路由指向网关。

R1

interface e0/0/0

ip address 10.0.4.1 24

quit

ip route-static 0.0.0.0 0.0.0.0 10.0.4.254

S3

interface vlanif 1

ip address 10.0.3.3 24

quit

ip route-static 0.0.0.0 0.0.0.0 10.0.3.254

R3

interface e0/0/0

ip address 10.0.6.3 24

quit

ip route-static 0.0.0.0 0.0.0.0 10.0.6.254

S4

interface vlanif 1

ip address 10.0.7.4 24

quit

ip route-static 0.0.0.0 0.0.0.0 10.0.7.254

6 检测VLAN3 和VLAN4 间的连通性

发现R1可以ping通S3

R1不可以ping通R3

由于网段10.0.6.0 24并非S1直连网段,且S1上也没有配置任何静态路由或用动态路由协议获取该网段的路由信息,因而S1没有通往该网段的路由条目,S1就无法将数据包正确转发到该网段。

7 在S1和S2上配置OSPF协议

S1

ospf

area 0

network 10.0.0.0 0.255.255.255

S2

ospf

area 0

network 10.0.0.0 0.255.255.255

待OSPF收敛完成后,查看S1的路由表

此时R1可以ping通R3