基于端口安全的 Jan16 公司网络组建
1.项目背景
Jan16 公司开发部为重要部门,所有员工使用指定的计算机工作, 为防止员工或访客使
用个人电脑接入网络, 将使用基于端口安全策略组建开发部网络。项目拓扑如图 1 所示,具
体要求如下:
(1) 开发部采用了华为可网管交换机作为接入设备;
(2) 出于安全的考虑,需在交换机的端口上绑定指定计算机的 MAC 地址,防止非法 计算机的接入;
(3) 计算机的 IP、 MAC 和接入交换机的端口信息如拓扑所示。
2.项目规划设计
MAC 地址是计算机的唯一物理标识,可以通过在交换机对应的端口上进行绑定,非绑定
的 MAC 将无法接入到网络中。查看 MAC 地址的方法有几种:
1、在计算机中执行 ipconfig 命令即可查看本机的 MAC 地址;
2、在计算机中执行 ARP -a 可以查看邻近计算机的 MAC 地址和 IP 地址;
3、在交换机上执行 display mac-address 命令可以查看对应的端口上的 MAC 地址。
在进行端口绑定时,需要查看两个信息,一个是计算机的 MAC 地址,另一个是计算机接
入的端口。因此,可以先从计算机查看本机的 MAC 地址,然后从交换机上查看 MAC 地址对应
的端口,最后进行 MAC 地址和端口的绑定。
配置步骤如下:
(1) 查看计算机本地 MAC 地址
(2) 查看 MAC 所在的交换机端口
(3) 开启该交换机端口的端口安全,并绑定对应的 MAC 地址
项目规划如下:
表 1 端口规划表
本端设备 | 端口号 | 对端设备 |
---|---|---|
SW1 | E0/0/1 | PC1 |
SW1 | E0/0/2 | PC2 |
SW1 | E0/0/3 | PC3 |
表 2 IP 地址规划表
计算机 | IP 地址 | MAC 地址 |
---|---|---|
PC1 | 192.168.10.1/24 | 54-89-98-CA-03-58 |
PC2 | 192.168.10.2/24 | 54-89-98-6F-0A-10 |
PC3 | 192.168.10.3/24 | 54-89-98-AE-46-88 |
3.项目实施
(1) 查看计算机本地 MAC 地址
配置好计算机 IP 地址, 在计算机命令行下输入 ipconfig,查看 MAC 地址。
PC1 的配置
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:feca:358
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.1
Subnet mask.......................: 255.255.255.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-CA-03-58
DNS server........................:
PC2的配置
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe6f:a10
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.2
Subnet mask.......................: 255.255.255.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-6F-0A-10
DNS server........................:
PC3的配置
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:feae:4688
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.3
Subnet mask.......................: 255.255.255.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-AE-46-88
DNS server........................:
(2) 查看 MAC 所在的交换机端口
在交换机上使用命令 display mac-address,查看交换机与计算机之间连接的端口,对
应 MAC 地址
<Huawei>system-view
[Huawei]sysname SW1
[SW1]
[SW1]display mac-address
MAC address table of slot 0:
-------------------------------------------------------------------------------
MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID
VSI/SI MAC-Tunnel
-------------------------------------------------------------------------------
5489-98ca-0358 1 - - Eth0/0/1 dynamic 0/-
5489-986f-0a10 1 - - Eth0/0/2 dynamic 0/-
5489-98ae-4688 1 - - Eth0/0/3 dynamic 0/-
-------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 3
(3) 开启该交换机端口的端口安全,并绑定对应的 MAC 地址
在交换机端口上打开端口安全功能, 将 MAC 地址绑定到相对应接口中,并在 vlan1 上有
效。
[SW1]interface Eth0/0/1
[SW1-Ethernet0/0/1]port-security enable
[SW1-Ethernet0/0/1]port-security mac-address sticky
[SW1-Ethernet0/0/1]port-security mac-address sticky 5489-98ca-0358 vlan 1
[SW1]interface Eth0/0/2
[SW1-Ethernet0/0/2]port-security enable
[SW1-Ethernet0/0/2]port-security mac-address sticky
[SW1-Ethernet0/0/2]port-security mac-address sticky 5489-986f-0a10 vlan 1
[SW1]interface Eth0/0/3
[SW1-Ethernet0/0/3]port-security enable
[SW1-Ethernet0/0/3]port-security mac-address sticky
[SW1-Ethernet0/0/3]port-security mac-address sticky 5489-98ae-4688 vlan 1
4.项目验证
(1)在交换机上查看配置是否生效
在交换机上使用 display mac-address 命令,查看交换机与计算机之间连接的端口,类
型是否变为 sticky。
[SW1]display mac-address
MAC address table of slot 0:
-------------------------------------------------------------------------------
MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID
VSI/SI MAC-Tunnel
-------------------------------------------------------------------------------
5489-98ae-4688 1 - - Eth0/0/3 sticky -
5489-98ca-0358 1 - - Eth0/0/1 sticky -
5489-986f-0a10 1 - - Eth0/0/2 sticky -
-------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 3
(2) 测试计算机的互通性
通过 Ping 命令,测试内部通信息的情况。
使用 PC1 计算机 Ping PC2 计算机:
PC>ping 192.168.10.2
Ping 192.168.10.2: 32 data bytes, Press Ctrl_C to break
From 192.168.10.2: bytes=32 seq=1 ttl=128 time=32 ms
From 192.168.10.2: bytes=32 seq=2 ttl=128 time=46 ms
From 192.168.10.2: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.10.2: bytes=32 seq=4 ttl=128 time=31 ms
From 192.168.10.2: bytes=32 seq=5 ttl=128 time=31 ms
--- 192.168.10.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms
使用 PC1 计算机 PingPC3 计算机:
PC>ping 192.168.10.3
Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break
From 192.168.10.3: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.10.3: bytes=32 seq=2 ttl=128 time=31 ms
From 192.168.10.3: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.10.3: bytes=32 seq=4 ttl=128 time=31 ms
From 192.168.10.3: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.10.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/40/47 ms
可以看出,计算机可以互相通信。
(3)更换计算机,测试互通性
把计算机 PC3,更换为计算机 PC4,IP 地址相同, MAC 地址不同,连接到交换机 Eth0/0/3
接口上。
查看 PC4 的 MAC 地址:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe87:617a
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.3
Subnet mask.......................: 255.255.255.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-87-61-7A
DNS server........................:
使用 PC1 计算机 Ping PC4 计算机:
PC>ping 192.168.10.3
Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
可以看出,更换计算机后, MAC 地址不同, 计算机不能通信。
tination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
可以看出,更换计算机后, MAC 地址不同, 计算机不能通信。