Switch#config terminal
#进入配置模式
Switch(config)# Interface fastethernet 0/1
#进入具体端口配置模式
Switch(config-if)#Switchport port-secruity
#配置端口安全模式
Switch(config-if )switchport port-security mac-address MAC(主机的MAC地址)
#配置该端口要绑定的主机的MAC地址
Switch(config-if )no switchport port-security mac-address MAC(主机的MAC地址)
#删除绑定主机的MAC地址
以上命令设置交换机上某个端口绑定一个具体的MAC地址,这样只有这个主机可以使用网络,如果对该主机的网卡进行了更换或者其他PC机想通过这个端口使用网络都不可用,除非删除或修改该端口上绑定的MAC地址,才能正常使用。
以上功能适用于思科2950、3550、4500、6500系列交换机
#定义一个MAC地址访问控制列表并且命名该列表名为MAC10
Switch(config)permit host 0009.6bc4.d4bf any
#定义MAC地址为0009.6bc4.d4bf的主机可以访问任意主机
Switch(config)permit any host 0009.6bc4.d4bf
#定义所有主机可以访问MAC地址为0009.6bc4.d4bf的主机
Switch(config-if )interface Fa0/20
#进入配置具体端口的模式
Switch(config-if )mac access-group MAC10 in
#在该端口上应用名为MAC10的访问列表(即前面我们定义的访问策略)
Switch(config)no mac access-list extended MAC10
#清除名为MAC10的访问列表
以上功能在思科2950、3550、4500、6500系列交换机上可以实现,但是需要注意的是2950、3550需要交换机运行增强的软件镜像(Enhanced Image)。
Switch(config)Mac access-list extended MAC10
#定义一个MAC地址访问控制列表并且命名该列表名为MAC10
Switch(config)permit host 0009.6bc4.d4bf any
#定义MAC地址为0009.6bc4.d4bf的主机可以访问任意主机
Switch(config)permit any host 0009.6bc4.d4bf
#定义所有主机可以访问MAC地址为0009.6bc4.d4bf的主机
Switch(config)Ip access-list extended IP10
#定义一个IP地址访问控制列表并且命名该列表名为IP10
Switch(config)Permit 192.168.0.1 0.0.0.0 any
#定义IP地址为192.168.0.1的主机可以访问任意主机
Permit any 192.168.0.1 0.0.0.0
#定义所有主机可以访问IP地址为192.168.0.1的主机
Switch(config-if )interface Fa0/20
#进入配置具体端口的模式
Switch(config-if )mac access-group MAC10 in
#在该端口上应用名为MAC10的访问列表(即前面我们定义的访问策略)
Switch(config-if )Ip access-group IP10 in
#在该端口上应用名为IP10的访问列表(即前面我们定义的访问策略)
Switch(config)no mac access-list extended MAC10
#清除名为MAC10的访问列表
Switch(config)no Ip access-group IP10 in
#清除名为IP10的访问列表
注意:
以上功能在思科2950、3550、4500、6500系列交换机上可以实现,但是需要注意的是2950、3550需要交换机运行增强的软件镜像(Enhanced Image)。