交换机的配置

如题所述

switchen switch#configureterminalswitch(conf)#hostnameaptech-2950aptech2950(conf)#enablepasswordcisco以cisco为特权模式密码aptech2950(conf)#interfacefastethernet0/1以17端口为telnet远程登录端口aptech2950(conf-if)#ipaddress192.168.1.1255.255.255.0aptech2950(conf-if)#noshutaptech2950(conf-if)#exitaptech2950(conf)linevty04设置0-4个用户可以telnet远程登陆aptech2950(conf-line)#loginaptech2950(conf-line)#passwordedge以edge为远程登录的用户密码
Switch用户模式
1.进入特权模式enable
Switchenable
2.进入全局配置模式
Switch#configture terminal
Switch (conf)#
3.交换机命名:
Switch#configture terminal
Switch (conf)#
Switch (conf)#hostname mycisco
Mycisco(conf)#
4.配置使能命令:
switchenable
switch#configure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)#enable secret ciscolab
5.创建VLAN
Switch #config t
Switch(conf)# vlan 2
Switch(conf)# vlan 3
Switch(conf)# vlan 4
Switch(conf) interface f0/2
Switch mode access
Switch access vlan2
Exit
No shutdown
# int f0/23
# sw mode trunk
# sw trunk enca dot1q
5.设置VLAN
Switchenable
Switch# conf t
Switch(conf)# hostname cisco
Cisco(conf)# interface vlan 2
#ip address 192.168.1.1 255.255.255.0
Exit
设置方法
一台3550EMI交换机,划分三个vlan
vlan2为服务器所在网络,命名为server,IP地址段为192.168.2.0,子网掩码:255.255.255.0,网
关:192.168.2.1,域服务器为windows 2000 advance server,同时兼作DNS服务器,IP地址为192.168.2.10
vlan3为客户机1所在网络,IP地址段为192.168.3.0,子网掩码:255.255.255.0,网关:192.168.3.1命名为
work01
vlan4为客户机2所在网络,命名为work02,IP地址段为192.168.4.0,子网掩码:255.255.255.0,网
关:192.168.4.1,
3550作DHCP服务器,端口1-8划到VLAN 2,端口9-16划分到VLAN 3,端口17-24划分到VLAN 4.
DHCP服务器实现功能:
各VLAN保留2-10的IP地址不分配置,例如:192.168.2.0的网段,保留192.168.2.2至192.168.2.10的IP地址
段不分配.
安全要求:
VLAN 3和VLAN 4不允许互相访问,但都可以访问服务器所在的VLAN2,
默认访问控制列表的规则是拒绝所有包.
配置命令及步骤如下:
第一步:创建VLAN:
Switchen
Switch#Vlan Database
Switch(Vlan)Vlan 2 Name server
Switch(Vlan)Vlan 3 Name work01
Switch(vlan)Vlan 4 Name work02
第二步:设置VLAN IP地址:
Switch#Config T
Switch(Config)Int Vlan 2
Switch(Config-vlan)Ip Address 192.168.2.1255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)Int Vlan 3
Switch(Config-vlan)Ip Address 192.168.3.1255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)Int Vlan 4
Switch(Config-vlan)Ip Address 192.168.4.1255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)Exit
/*注意:由于此时没有将端口分配置到VLAN2,3,4,所以各VLAN会DOWN掉,待将端口分配到各VLAN后,VLAN会起来*/
第三步:设置端口全局参数
Switch(Config)Interface Range Fa 0/1 - 24
Switch(Config-if-range)Switchport ModeAccess
Switch(Config-if-range)Spanning-treePortfast
第四步:将端口添加到VLAN2,3,4中
/*将端口1-8添加到VLAN 2*/
Switch(Config)Interface Range Fa 0/1 - 8
Switch(Config-if-range)Switchport AccessVlan 2
/*将端口9-16添加到VLAN 3*/
Switch(Config)Interface Range Fa 0/9 - 16
Switch(Config-if-range)Switchport AccessVlan 3
/*将端口17-24添加到VLAN 4*/
Switch(Config)Interface Range Fa 0/17 - 24
Switch(Config-if-range)Switchport AccessVlan 4
Switch(Config-if-range)Exit
/*经过这一步后,各VLAN会起来*/
第五步:配置3550作为DHCP服务器
/*VLAN 2可用地址池和相应参数的配置,有几个VLAN要设几个地址池*/
Switch(Config)Ip Dhcp Pool Test01
/*设置可分配的子网*/
Switch(Config-pool)Network 192.168.2.0255.255.255.0
/*设置DNS服务器*/
Switch(Config-pool)Dns-server 192.168.2.10
/*设置该子网的网关*/
Switch(Config-pool)Default-router192.168.2.1
/*配置VLAN 3所用的地址池和相应参数*/
Switch(Config)Ip Dhcp Pool Test02
Switch(Config-pool)Network 192.168.3.0255.255.255.0
Switch(Config-pool)Dns-server 192.168.2.10
Switch(Config-pool)Default-router192.168.3.1
/*配置VLAN 4所用的地址池和相应参数*/
Switch(Config)Ip Dhcp Pool Test03
Switch(Config-pool)Network 192.168.4.0255.255.255.0
Switch(Config-pool)Dns-server 192.168.2.10
Switch(Config-pool)Default-router192.168.4.1
第六步:设置DHCP保留不分配的地址
Switch(Config)Ip Dhcp Excluded-address192.168.2.2 192.168.2.10
Switch(Config)Ip Dhcp Excluded-address192.168.3.2 192.168.3.10
Switch(Config)Ip Dhcp Excluded-address192.168.4.2 192.168.4.10
第七步:启用路由
/*路由启用后,各VLAN间主机可互相访问*/
Switch(Config)Ip Routing
第八步:配置访问控制列表
Switch(Config)access-list 103 permit ip192.168.2.0 0.0.0.255 192.168.3.0 0.0.0.255
Switch(Config)access-list 103 permit ip192.168.3.0 0.0.0.255 192.168.2.0 0.0.0.255
Switch(Config)access-list 103 permit udpany any eq bootpc
Switch(Config)access-list 103 permit udpany any eq tftp
Switch(Config)access-list 103 permit udpany eq bootpc any
Switch(Config)access-list 103 permit udpany eq tftp any
Switch(Config)access-list 104 permit ip192.168.2.0 0.0.0.255 192.168.4.0 0.0.0.255
Switch(Config)access-list 104 permit ip192.168.4.0 0.0.0.255 192.168.2.0 0.0.0.255
Switch(Config)access-list 104 permit udpany eq tftp any
Switch(Config)access-list 104 permit udpany eq bootpc any
Switch(Config)access-list 104 permit udpany eq bootpc any
Switch(Config)access-list 104 permit udpany eq tftp any
第九步:应用访问控制列表
/*将访问控制列表应用到VLAN 3和VLAN 4,VLAN2不需要*/
Switch(Config)Int Vlan 3
Switch(Config-vlan)ip access-group 103 out
Switch(Config-vlan)Int Vlan 4
Switch(Config-vlan)ip access-group 104 out
第十步:结束并保存配置
Switch(Config-vlan)End
Switch#Copy Run Start
温馨提示:答案为网友推荐,仅供参考
相似回答