ensp-VLAN基础配置及Access接口(第八天)

概述:
早期局域网技术基于总线接口(是由一根单电缆连接所有主机)所有主机在一个局域网中会出现冲突问题,同一时间只能有一台主机发送消息(都会被其他主机接收)这样别的主机也会接收不需要的报文,主机之间也会互相访问,从而无法保证信息安全的安全性。
为了避免冲冲突域并扩展传统接入更多的主机,可以使用二层交换机,但由于所有计算机仍处于一个广播域,任意报文都能接收所有报文,不但降低网络的效率更降低了安全性,既仍然存在问题
为了减少广播,提高安全性,人们使用虚拟局域网既VLAN技术把一个物理的LAN在逻辑上划分成多个广播域,VLAN内的主机间可以直接通信,而VLAN间不能直接通信,这样可以把报文限制在一个VLAN内,同时提高安全性,不同的VLAN使用不通的VLAN ID区分,VLAN ID 的范围是 0~4095 ,可配置的值为 1~4094 , 0 和 4095为保留值
Access接口是交换机用来连接用户主机的接口,Access接口从主机收到一个不带VLAN标签的数据帧,会给数据帧加上与PVID一致的VLAN标签(PVID可手工配置,默认是1,既所有交换机的默认都属于VLAN 1)
当Access接口要发送一个带VLAN标签的数据帧给主机时,先检查该数据帧的·VLAN ID 是否与自己的PVID相同,若相同,则去掉VLAN标签后发送数据帧給主机、不同,直接丢弃该数据


1、基本配置完成,并进行检测互通性
PC>ping 10.1.1.3

Ping 10.1.1.3: 32 data bytes, Press Ctrl_C to break
From 10.1.1.3: bytes=32 seq=1 ttl=128 time=47 ms
From 10.1.1.3: bytes=32 seq=2 ttl=128 time=47 ms

— 10.1.1.3 ping statistics —
2 packet(s) transmitted
2 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/47/47 ms
其他主机也是一样,略过


2、创建VLAN
默认只有一个VLAN 1,其余的需要手动来创建,有两种方法创建:用vlan命令单独创建和vlan batch创建多个
在S1上分别创建VLAN 10和VLAN20
[S1]vlan 10
[S1-vlan10]
Sep 1 2020 11:32:30-08:00 S1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 5, the ch
ange loop count is 0, and the maximum number of records is 4095.
[S1-vlan10]vlan 20
[S1-vlan20]
Sep 1 2020 11:33:10-08:00 S1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 6, the ch
ange loop count is 0, and the maximum number of records is 4095.
使用vlan batch命令创建VLAN 30和VLAN 40
[S2]vlan batch 30 40

配置完成后,在S1、S2上使用display vlan 查看VLAN的相关信息
[S1]display vlan

The total number of vlans is : 3

U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking;
ProtocolTransparent-vlan; *: Management-vlan;

VID Type Ports


1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(U) Eth0/0/4(D)
Eth0/0/5(U) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D)
Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D)
Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D)
Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D)
Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D)

10 common
20 common

VID Status Property MAC-LRN Statistics Description


1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 [S1] [S2]display vlan Sep 1 2020 11:49:49-08:00 S2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25. 191.3.1 configurations have been changed. The current change number is 5, the ch ange loop count is 0, and the maximum number of records is 4095. The total number of vlans is : 3 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports


1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(D) Eth0/0/4(D)
Eth0/0/5(U) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D)
Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D)
Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D)
Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D)
Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D)

30 common
40 common

VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 30 enable default enable disable VLAN 0030 40 enable default enable disable VLAN 0040 [S2] 可以观察到S1、S2都创建了相应的VLAN,但目前没有任何借口加入所创建的VLAN 10与20中,默认情况下交换机上所有接口都属于VLAN 1

3、配置Acess接口
使用port link-type access命令配置所有S1和S2交换机连接的Access类型接口,并使用port default vlan 命令配置接口默认的vlan (默认vlan id 为 1)

[S1]int e0/0/1
[S1-Ethernet0/0/1]port link-type access
[S1-Ethernet0/0/1]port default vlan 10
[S1-Ethernet0/0/1]int e0/0/2
[S1-Ethernet0/0/2]port link-type access
[S1-Ethernet0/0/2]port default vlan 10
[S1-Ethernet0/0/2]int e0/0/3
[S1-Ethernet0/0/3]port link-type access
[S1-Ethernet0/0/3]port default vlan 20

[S2]int e0/0/1
[S2-Ethernet0/0/1]port link-type access
[S2-Ethernet0/0/1]port default vlan 30
[S2-Ethernet0/0/1]int e0/0/2
[S2-Ethernet0/0/2]port link-type access
[S2-Ethernet0/0/2]port default vlan 40

配置完成后,使用display vlan 查看S1、S2的vlan的信息 [S1]display vlan The total number of vlans is : 3 --------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; ---------------------------------------------------------------- VID Type Ports

1 common UT:Eth0/0/4(D) Eth0/0/5(U) Eth0/0/6(D) Eth0/0/7(D)
Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D)
Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D)
Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D)
Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D)
GE0/0/2(D)

10 common UT:Eth0/0/1(U) Eth0/0/2(U)

20 common UT:Eth0/0/3(U)

VID Status Property MAC-LRN Statistics Description


1 enable default enable disable VLAN 0001
10 enable default enable disable VLAN 0010
20 enable default enable disable VLAN 0020

[S2]display vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports


1 common UT:Eth0/0/3(D) Eth0/0/4(D) Eth0/0/5(U) Eth0/0/6(D)
Eth0/0/7(D) Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D)
Eth0/0/11(D) Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D)
Eth0/0/15(D) Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D)
Eth0/0/19(D) Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D)
GE0/0/1(D) GE0/0/2(D)

30 common UT:Eth0/0/1(U)

40 common UT:Eth0/0/2(U)

VID Status Property MAC-LRN Statistics Description


1 enable default enable disable VLAN 0001
30 enable default enable disable VLAN 0030
40 enable default enable disable VLAN 0040

目前两台交换机连接pc的接口都已经加入到相应vlan当中


交换机上将不同接口加入到不同vlan中后,属于相同vlan的接口处于同一个广播域,相互之间可以通信 , 属于不同vlan接口是处于不同的广播域,不能正常通信
测试连通性
PC>ping 10.1.1.2

Ping 10.1.1.2: 32 data bytes, Press Ctrl_C to break
From 10.1.1.2: bytes=32 seq=1 ttl=128 time=31 ms
From 10.1.1.2: bytes=32 seq=2 ttl=128 time=32 ms

— 10.1.1.2 ping statistics —
2 packet(s) transmitted
2 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/31/32 ms

PC>ping 10.1.1.3

Ping 10.1.1.3: 32 data bytes, Press Ctrl_C to break
From 10.1.1.1: Destination host unreachable
From 10.1.1.1: Destination host unreachable
From 10.1.1.1: Destination host unreachable

— 10.1.1.3 ping statistics —
3 packet(s) transmitted
0 packet(s) received
100.00% packet loss

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

忘_忧

留个打赏呗

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值