Cisco交换机Vlan划分及ACL配置详细步骤

关注安全
0 592

一、开机

1、如是新设备,开机需跳过系统默认配置模式,进入手动配置模式。

2、进入用户模式,系统提示符为 >,此模式只能查看统计信息,无配置功能。

3、用户模式下,输入 enable ,进入特权模式,系统提示符为 #。

二、一些常用设置

1、设置enable密码

(config)#enable password XXX

2、设置主机名

(config)#hostname XXX

3、关闭http访问

(config)#no httpserver

4、关闭密码明文显示

(config)#service password-encryption

5、配置consol口密码

(config)#line con 0

(config-line)#password XXX

(config-line)#login

(config-line)#exit

6、启用三层交换机路由功能(如三层交换机有多个VLAN需要开启此功能)

(config)#ip routing       //启用三层交换机的路由的功能

7、开启/关闭telnet访问

(config)#line vty 0 4

开启:

switch(config-line)#password 你的密码

switch(config-line)#login

关闭:

(config-line)#no password

(config-line)#exit

8、配置端口IP地址

Switch>enable

Switch#configure terminal

Switch(config)#interface f0/1

Switch(config-if)#no switchport  --启用此端口三层交换机功能

Switch(config-if)#ip address 192.168.0.1 255.255.255.0

Switch(config-if)#no shutdown

9、关闭VLAN 1

(config)#interface vlan 1

(config-if)#shutdown

(config-if)#exit

三、创建VLAN 10   (vlan 1 设备自动生成,不能更改、删除)

方法1:

# vlan database

(vlan)# vlan 10 name XXX

(vlan)#apple

方法2:

#configure terminal

(config)#vlan 10

(config-vlan)#name XXX

(config-vlan)#exit

四、Vlan配置

# configure terminal

(config-if)#interface vlan 10  --进入Vlan 10

(config-if)#ip address 192.168.10.254 255.255.255.0  --配置此Vlan网关地址为192.168.10.254

(config-if)#no shutdown  --开启端口

(config-if)#description XXX  --描述名XXX,只支持英文

(config-if)#exit  --退出

五、添加Vlan到某个端口

#show run  --可查看到各个端口允许Vlan信息

#show ip int brief  --查看端口状态

#show int f0/6(端口),  --查看端口6详细信息

#configure terminal

(config)#interface range gigabitEthernet 0/16  --进入端口16

(config-if-rang)#no shutdown  --开启端口

(config-if-rang)#switchport mode access  --将交换机端口转换为ACCESS模式(一般不需要设置这个)

(config-if-rang)#switchport access vlan 10  --在16端口允许Vlan 10通过

(config-if-rang)#no switport access vlan 10  --删除此端口的Vlan信息

(config-if-rang)#exit  --退出

六、单独修改某个Vlan网关

(config-if)#interface vlan 10  --进入Vlan 10

(config-if)#ip address 192.168.10.254 255.255.255.0  --配置此Vlan网关地址为192.168.10.254

七、创建ACL规则

(config)#ip access-list extended swj(ACL规则名)

(config-ext-nacl)#deny ip 192.168.30.0 0.0.0.255 192.168.10.0 0.0.0.255

----拒绝vlan30的用户访问vlan10资源

八、将ACL应用到 vlan10

(config)#interface vlan 10  --创建vlan10的SVI接口

(config-if)#ip access-group swj in  --将扩展ACL应用到vlan10的SVI接口下

九、ACL策略添加编辑

(config)#ip access-list extended BGS(ACL规则名)  --进入BGS

(config-ext-nacl)#91 permit ip host 201.123.116.230 192.168.10.0 0.0.0.255

--允许192.168.10.0网段访问201.123.116.230

(config-ext-nacl)#92 permit ip host 201.123.116.230 host 201.123.123.233

--允许201.123.123.233访问201.123.116.230

(config-ext-nacl)#100 deny ip 201.123.116.0 0.0.0.255 201.123.123.0 0.0.0.255

--禁止123网段访问116网段

(config-ext-nacl)#no 10 permit host 201.123.123.233 host 201.123.119.34  --删除编号为10的规则

十、保存

#copy run-configure start-configure