如何判断用直通线或交叉线:
设备口相同:交叉线;设备口不同:直通线.
DCRS-5650-28(config)#hostname swx
特权用户密码:
DCRS-5650-28(config)#enable password shenzhou (明文方式)
DCRS-5650-28(config)#enable password 8 shenzhou (密文方式)
Telnet登陆管理:
DCRS-5650-28(config)#telnet-user shenzhou password 0 digital
Route
Router_config#hostname Rx
特权用户密码:
Rx_config#enable password 0 shenzhou level 15(设置最高级别的明文密码)
Rx_config#enable password 7 shenzhou level 15(设置最高级别的密文密码)
Rx_config#aaa authentication enable default enable(设置aaa验证)
Telnet登陆管理:
Rx_config#username client password shenzhou(设置Telnet用户名和密码)
Rx_config#aaa authentication login default local(设置本地用户信息进行验证)
Rx_config#aaa authentication enable default none(设置特权用户信息进行验证)
(line命令可以不用)
Rx_config#line vty 0 4(最多允许4个用户登陆)
Rx_config_line#login authentication default(Telnet使用默认认证列表)
经过测试,配置路由器时,设置telnet时,需同时设置login,enable验证,否则会出现“验证错误”
经过测试,配置交换机时,用户的建立注意设置级别,否则用户在telnet,web管理登录时,不能进入特权模式或提示用户权限不足。
#clock set 00:00:00 2010.10.16
#date
DCRS-5650-28(config)#vlan 100(创建VLAN)
DCRS-5650-28(config-vlan100)#switchport interface e0/0/1-3(把E1-3端口加入VLAN)(EXIT/INTERFACE rang F0/1-3/SWITCHPORT access vlan 100)
DCRS-5650-28(config-vlan100)#switchport interface e0/0/4;6(把E4、E6端口加入VLAN)
DCRS-5650-28(config)#int vlan 100 (设置VLAN)
DCRS-5650-28(config-if-vlan100)#ip address 1.1.1.1 255.255.255.0(设置VLAN的IP)
相同VLAN间的通信:
DCRS-5650-28(config-if-vlan100)#int e0/0/1
DCRS-5650-28(config-if-ethernet0/0/1)#switchport trunk encapsulation dot1q(封装)
DCRS-5650-28(config-if-ethernet0/0/1)#switchport mode trunk(设置接口为中继模式)
DCRS-5650-28(config-if-ethernet0/0/1)#switchport trunk allowed vlan all
(设置允许通过该端口的所有VLAN)
经测试,在设置跨交换机的vlan间通信时,两交换机所连的端口都需设置中继
私有VLAN:
(用于vlan间的互访,进到vlan中配置)
private-vlan [ primary | community | isolated | association ] (主| 团体| 隔扇| 联合 )
switch(Config)#vlan 100
switch(Config-Vlan100)#private-vlan primary (设置主vlan)
switch(Config)#vlan 200
switch(Config-Vlan200)#private-vlan community (设置群体vlan)
switch(Config)#vlan 300
switch(Config-Vlan300)#private-vlan community (设置群体vlan)
switch(Config)#vlan 400
switch(Config-Vlan400)#private-vlan isolated (设置隔离vlan)
switch(Config)#vlan 100
switch(Config-Vlan100)#private-vlan association 200;300;400 (vlan 之间的关联)
switch(Config-Vlan100)#switchport interface ethernet 0/0/1-4
switch(Config-Vlan100)#vlan 200
switch(Config-Vlan200)#switchport interface ethernet 0/0/7-12
switch(Config-Vlan200)#vlan 300
switch(Config-Vlan300)#switchport interface ethernet 0/0/13-18
switch(Config-Vlan300)#vlan 400
switch(Config-Vlan400)#switchport interface ethernet 0/0/19-24
创建私有 vlan 的时候,先做关联,再添加端口。因为关联时,会自动把原vlan 的
端口移除。
相关命令:
Vlan //创建VLAN,是VID号;
Name //给VLAN命名;
Switchport access vlan //处于某个access端口状态,将当前端口加入到指定的vlan中;
Switchpor interface //进入vlan状态,将一个或多个端口添加到vlan中;
Switchport mode {trunk|access} //设置交换机的端口access或trunk模式;
Switchport trunk allowed VLAN ALL //设置trunk端口允许通过所有VLAN;
Switchport trunk native vlan //设置trunk端口的PVID;
Vlan ingress disable //关闭端口的VLAN入口规则。
出入带宽限制 bandwidth control * [both | transmit | receive ]
限制广播数据包 rate-suppression broadcast *
镜像 (监控,在全局下) 源:monitor session 1 source inter 0/0/1 [both| rx | tx ]
目的:monitor session 1 destination inter 0/0/2
双工模式 speed-duplex force[10/100-half/full | auto ]
MAC绑定 switch port-security
switch port-security maximum *(地址最大数)
switch port-security mac-address 00-00-00-00-00-00
swi port lock (锁定端口)
swi port violation shutdown /protect 超出就shutdown
流控 flow control
端口配置网线模式 mdi [across | normal | auto ]
设置trunk 模式
用于二层与三层,或三层与三层间的传输。
在端口模式下设置:
int e0/0/1
switch mode trunk 干道模式
switch trunk allow vlan all 跨交换机之间相同的VLAN能够互通
交换机端口安全
1、绑定MAC地址与端口绑定:
DCRS-5650-28(config)#int e0/0/2
DCRS-5650-28(config-if-ethernet0/0/2)#switchport port-security(启动端口安全模式)
DCRS-5650-28(config-if-ethernet0/0/2)#switchport port-security mac-address 00-00-00-00-00-01 (绑定端口连接的网卡mac地址)
DCRS-5650-28(config-if-ethernet0/0/2)#switchport port-security lock(锁定安全端口)
2、配置MAC 地址表实现绑定和过滤:
DCRS-5650-28A(config)#mac-address-table static address 00-25-11-8b-7c-6d vlan 1 interface ethernet 0/0/1 (绑定MAC和端口)
DCRS-5650-28A(config)#mac-address-table static address 00-25-11-8b-81-cd vlan 1 interface ethernet 0/0/2 (绑定MAC和端口)
3、交换机MAC 与IP 的绑定: am enable;am mac_ip-pool
注:5650-28没有此命令,5650-28C有此命令
DCRS-5650-28A(config)#am enable
DCRS-5650-28A(config)#int e0/0/1
DCRS-5650-28A(config)#am port
DCRS-5650-28A(config-if-ethernet0/0/1)#am mac-ip-pool 00-25-11-8b-81-cd 192.168.1.101
查看配置:
DCRS-5650-28A(config)#show am
解锁:
DCRS-5650-28A(config-if-ethernet0/0/1)#no am port
相关命令:
am ip-pool[num]// 创建一个IP地址段,放到地址池中。
Am port //打开或关闭物理接口上的AM功能
No am all //删除全部用户配置的MAC-IP地址池或者IP地址池。
Show am //查看当前交换机配置的地址项。
流量控制:
DCRS-5650-28(config-if-port-range)#bandwidth control 5000 transmit
(端口带宽出口为5Mbps)
DCRS-5650-28(config-if-port-range)#bandwidth control 2000 receive
(端口带宽入口为2Mbps)
镜像端口:
SW1(config)#monitor session 1 source interface ethernet 0/0/11-12(E11-12为端口源镜像)
SW1(config)#monitor session 1 destination interface ethernet 0/0/10(E10为镜像目的端口)
端口流控制:
SW2(config-if-ethernet0/0/6)#name SW1-F6-FLOW
SW2(config-if-ethernet0/0/6)#flow control
4、 交换机端口、链路汇聚
用于交换机之间的互连,连接线两条以上,增大带宽
流程:
port-group 1 创建汇聚组
inter e0/0/1 进入端口下配置
port-group 1 mode [ on | active | passive ](模式mode根据需求设定 )
inter port-channel 1 进入汇聚组下进行配置
switch mode trunk 配置干道模式(根据实际情况设置)
SW1(config)#port-group 1 (创建port-group)
SW1(config)#int e0/0/22-23 (进入端口22,23)
SW1(config-if-port-range)#port-group 1 mode on (强制端口加入port-channel,不启动LACP协议)
SW1(config-if-port-range)#interface port-channel 1 (进入聚合端口)
SW1(config-if-port-channel1)#switchport mode trunk (设置聚合端口为骨干端口)
SW2(config)#port-group 1 (创建port-group)
SW2(config)#int e0/0/22-23 (进入端口22,23)
SW2(config-if-port-range)#port-group 1 mode on (强制端口加入port-channel,不启动LACP协议)
SW2(config-if-port-range)#interface port-channel 1 (进入聚合端口)
SW2(config-if-port-channel1)#switchport mode trunk (设置聚合端口为骨干端口)
DCRS-5650-28(config)#spanning-tree(启动生成树)(默认开启MSTP 协议)
DCRS-5650-28(Config)#spanning-tree mode stp(运行STP模式)
阻断15S,学习15S,转发20S
设置spanning-tree的mode时需先启动生成树协议
Switch(Config)#spanning-tree priority 0(设置交换机为根网桥)
MSTP典型配置:
SW(Config)#vlan 20
SW(Config-Vlan20)#exit
SW(Config)#vlan 30
SW(Config-Vlan30)#exit
SW(Config)#vlan 40
SW(Config-Vlan40)#exit
SW(Config)#vlan 50
SW(Config-Vlan50)#exit
SW(Config)#spanning-tree mst configuration (进入MSTP域配置模式)
SW(Config-Mstp-Region)#name mstp (配置MSTP域的名字)
SW(Config-Mstp-Region)#instance 3 vlan 20;30
(创建Instance及配置VLAN与Instance的映射关系)
SW(Config-Mstp-Region)#instance 4 vlan 40;50
SW(Config-Mstp-Region)#exit
SW(Config)#interface e0/0/1-7
SW(Config-Port-Range)#switchport mode trunk
SW(Config-Port-Range)#exit
SW(Config)#spanning-tree
SW(Config)#spanning-tree mst 4 priority 0
(配置交换机为实例4的根网桥;配置实例4对应的网桥优先级为0)
多层交换机VLAN的划分和VLAN间路由
划分VLAN
增加端口(端口不连续用“,”)
对VLAN端口设置IP
SW(Config)#interface vlan 100
SW(Config- if-vlan 100)#ip address 192.168.1.1 255.255.255.0
SW(Config- if-vlan 100)#no shut
SW(Config- if-vlan 100)#exit
SW(Config)#interface vlan 200
SW(Config- if-vlan200)#ip address 192.168.2.1 255.255.255.0
SW(Config- if-vlan 200)#no shut
SW(Config- if-vlan 200)#exit
SW(Config)#sh ip route //查看路由配置`在这里插入代码片`
相关命令:
实例:
在S1 上划分VLAN与端口
vlan1----switch inter f0/5
vlan2----switch inter f0/6
将连接路由的接口设置为TRUNK与802.1q
switch trunk encap dot1q
switch mode trunk
在路由器的物理以太网接口下创建子接口,并定义封装类型
inter f0/0
no shutdown
inter f0/0.1
encapture dot1q 1 native 交换机上的默认VLAN1 ,已设置的vlan
ip add 172.16.1.254 255.255.255.0
inter f0/0.2
encapture dot1q 2 VLAN2
ip add 172.16.2.254 255.255.255.0
注意事项:
1.进行完基础配置之后,就开始接通网络(保证能通),达到各网络能够互访
2. rip/ospf 所配置的子网是属于直连的网络,先用show ip route 查找
3. ip route 所配置的子网是非直连的网络,清楚源地址指向目的地址
4. 注意交换机与路由配置的不同点。
5.当出现多动态路由的时候,一个网段只声明一次,要注意重发布redistribute 的使用
具体配置如下:
ip route 流程
ip route 10.1.1.0 0.0.0.255 192.168.0.1 ( 先目的IP网络,后边是下一跳入端口ip或是本地端口)
rip 流程
router rip 开启rip
version [ 1 |2 ] 选择版本
no auto-summary 在路由下起用关闭自动汇总
network 192.168.0.0 声明直连网段
default-information originate 宣告默认路由
(注:同时使用ospf、静态路由时,要在rip下,重发布ospf 、静态路由static、直连网络connected )
ospf 流程
router ospf 1 开启ospf
network 192.168.0.0 0.0.0.255 area 0 声明直连网段与反码,后边是区域
(注: 同时使用rip、静态路由时,要在ospf下,重发布rip 、静态路由static、直连网络connected )
用OSPF进行MD5验证( 先启动后设置,再到端口上应用)
router ospf 1
network 192.168.0.0 0.0.0.255 area 0
area 0 authen message-digest 设置区域0启动MD5验证协议
到端口上:
int f0/0
ip ospf authen message-degest 设置端口以MD5方式验证
ip ospf m-d-key 120 md5 test 设置端口的认证ID和密钥
distance 1 设置OSPF 的管理距离为1(OSPF)
R1_config#router ospf 1
R1_config_ospf_1#network 10.2.1.4/30
R1_config_ospf_1#network 10.2.1.4 255.255.255.252 area 0
R1_config_ospf_1#network 10.43.5.0 255.255.255.252 area 0
R1_config_ospf_1#network 172.16.1.0 255.255.255.0 area 0
R2_config#router ospf 1
R2_config_ospf_1#network 10.43.5.0 255.255.255.252 area 0
R2_config_ospf_1#network 202.192.36.0 255.255.255.0 area 0
R2_config_ospf_1#network 202.192.36.0 255.255.255.0 area 0
SW1(config)#router ospf 1
SW1(config-router)#network 192.168.2.64/26 area 0
SW1(config-router)#network 202.192.36.0/24 area 0
SW2(config)#router ospf 1
SW2(config-router)#network 202.192.37.0/24 area 0
SW2(config-router)#network 192.168.2.128/26 area 0
默认路由
ip route 0.0.0.0 0.0.0.0 [ f0/0] 后边是指下一跳端口
(策略路由)(绑定在源数据包进入路由器的接口)
配置特定的路径,让某个网络发出的数据包只能转发到某个特定的接口。
同一个路由设置多个策略时,只要更改序号,还是用同个名称,再用到端口。
流程:
先允许某个网络通过:用ACL
R1_config#ip access-list standard pbr (定义ACL)
R1_config_std_nacl#permit 10.2.1.5 255.255.255.255 (设置需要进行策略路由的源地址)
创建策略路由
R1_config#route-map pbr 10 permit (定义Route-map)(配置策略路由的名称和序号)
R1_config_route_map#match ip address pbr (设定源地址)(应用ACL)
R1_config_route_map#set ip next-hop 172.16.1.254 (设定下一跳)(下一跳入端口的IP)
应用到端口上
R1_config_route_map#int f0/0 (进入源地址的路由器接口)
R1_config_f0/0#ip policy route-map pbr (绑定Route-map)
time-range
参数: absolute 配置绝对时间范围
absolute-periodic 配置周期性绝对时间段
periodic 配置周期时间段
absolute start 9:0:0 2009.3.13 end 18:0:0 2010.3.13 //2009年3月13日至2010年3月13日
absolute-periodic Tuesday 9:15:30 to Saturday 12:30:00 //在Tuesday到Saturday内的9:15:30到12:30:00时间段
periodic Monday Wednesday Friday Sunday 14:30:00 to 16:45:00 //Monday、Wednesday、Friday和Sunday四天内的14:30:00到16:45:00
交换机:(必须开启firewall)
SW1(config)#ip access-list extended ddb (定义名为ddb的ACL)
SW1(config-ip-ext-nacl-ddb)#deny tcp any-source any-destination d-port 445 (关闭445端口)
SW1(config-ip-ext-nacl-ddb)#permit ip any-source any-destination (允许通过所有IP数据包)
SW1(config)#firewall enable (配置ACL功能开启)
SW1(config)#firewall default permit (默认动作为全部允许通过)
SW1(config)#interface e0/0/1-24 (进入接口模式)
SW1(config-if-port-range)#ip access-group ddb in (绑定ACL)
路由器:(注意隐含的DENY)
R1_config#ip access-list extended denyvlan20
R1_config_ext_nacl#deny ip 192.168.2.128 255.255.255.192 any
R1_config_ext_nacl#permit ip any any
R1_config#interface f0/0
R1_config_f0/0#ip access-group denyvlan20 out