第一章:设备配置和文件管理

1.1 通过 TELNET方式来配置设备

  • 提问:如何通过 telnet方式来配置设备?

  • 回答:步骤一:配置 VLAN1的 IP地址

    S5750>en                ----进入特权模式
    S5750#conf              ----进入全局配置模式
    S5750(config)#int vlan 1     ----进入 vlan 1接口   
    S5750(config-if)#ip address 192.168.0.230 255.255.255.0    ----为 vlan 1接口上设置管理 ip  
    S5750(config-if)#exit                        ----退回到全局配置模式
  • 步骤二:配置telnet密码

    S5750(config)#line vty 0 4              ----进入telnet密码配置模式,0 4表示允许共5个用户同时telnet登入到交换机
    S5750(config-line)#login           ---启用需输入密码才能telnet成功
    S5750(config-line)#password ruijie   ---将telnet密码设置为ruijie
    S5750(config-line)#exit                ---回到全局配置模式
    S5750(config)#enable secret 0 ruijie    ---配置进入特权模式的密码为ruijie
  • 步骤三:开启SSH服务(可选操作)

    S5750(config)#enable service ssh-server         ---开启ssh服务
    S5750(config)#ip ssh version 2   ---启用ssh version 2
    S5750(config)#exit     ---回到特权模式
    S5750#wri             ---保存配置

    1.2 更改 IOS命令的特权等级

  • 提问:如何只允许dixy这个用户使用与ARP相关的命令?

  • 回答:

    S5750(config)#username dixy password dixy  ---设置 dixy用户名和密码
    S5750(config)#username dixy privilege 10   ---dixy帐户的权限为 10
    S5750(config)#privilege exec level 10 show arp  ---权限 10可以使用 show arp命令   
    S5750(config)#privilege config all level 10 arp       ---权限 10可以使用所有 arp打头的命令   
    S5750(config)#line vty 0 4             ----配置 telnet登陆用户
    S5750(config-line)#no password
    S5750(config-line)#login local    
    注释: 15级密码为 enable特权密码,无法更改, 0级密码只能支持 disable,  enable, exit和 help, 1级密码无法进行配置。

1.3设备时钟设置

  • 提问:如何设置设备时钟?
  • 回答:
    S5750#clock set 12:45:55 11 25 2019       ---设置时间为2008年11月25日12点45分55秒
    S5750#clock update-calendar         ---设置日历更新  
    S5750(config)#clock timezone CN 8 22    ---时间名字为中国,东8区22分
    S5750(config)#ntp server 192.168.1.1
    S5750(config)#show ntp status

1.4把日志发送到日志服务器

Ruijie#configure terminal
Ruijie(config)#service sequence-numbers ------>开启在日志中显示序号
Ruijie(config)#service timestamps ------>开启在日志中显示时间戳
Ruijie(config)#interface vlan 1
Ruijie(config-if-VLAN 1)#ip address 192.168.1.1 255.255.255.0
Ruijie(config-if-VLAN 1)#exit
Ruijie(config)#logging server 192.168.1.2 ------>指定日志服务器IP地址
Ruijie(config)#logging source ip 192.168.1.1 ------>指定与日志服务器通信的源IP地址
Ruijie(config)#logging trap 7 ------>(可选)配置哪些日志信息发往Syslog Server,7代表记录所有日志(包括debug信息)
Ruijie(config)#end

第二章:交换机基础配置

2.1交换机vlan和trunk的配置

  • 提问:如何在交换机上划分 vlan,配置 trunk接口?
  • 回答: 步骤一:给交换机配置IP地址
    S2724G#conf 
    S2724G(config)#int vlan 1 
    S2724G(config-if)#ip addess 192.168.0.100 255.255.255.0 ---给 VLAN 1配置 IP地址   
    S2724G(config-if)#no shutdown           ---激活该 VLAN接口
    S2724G(config-if)#exit 
    S2724G(config)#ip default-gateway 192.168.0.1 ---指定交换机的网关地址

    步骤二:创建 VLAN

    S2724G#conf 
    S2724G(config)#vlan 10      ---创建 VLAN 10
    S2724G(config-vlan)#exit 
    S2724G(config)# vlan 20     ---创建 VLAN 20
    S2724G(config-vlan)#exit

步骤三:把相应接口指定到相应的 VLAN中

S2724G(config)#int gi 0/10 
S2724G(config-if)#switch access vlan 10  ---把交换机的第10端口划到VLAN 10中  
S2724G(config-if)#exit
S2724G(config)#int gi 0/20 
S2724G(config-if)#switch access vlan 20 ---把交换机的第20端口划到VLAN 20中  
S2724G(config-if)#exit
S2724G(config)#int gi 0/24 
S2724G(config-if)#switch mode trunk   --设置24口为Trunk模式(与三层交换机的连接口  

步骤四:保存配置

S2724G(config-if)#end
S2724G#write
S2724G#reload //重启

S2724G>dir //查看目录
S2724G>del config.text //删除配置恢复出厂设置
S2724G>remove config.text

S2724G(config)#show run int g 0/1 查看当前接口配置

在锐捷交换机中,怎样将多个端口同时划分到一个vlan中?

interface range g 0/1-10
sw acc vl 10

2.2 turnk接口修剪配置

  • 提问:如何让 trunk接口只允许部分 vlan通过?
  • 回答:
    Switch(config)#int fa 0/24 
    Switch (config-if)#switch mode trunk 
    Switch (config-if)#switchport trunk allowed vlan remove 10,20,30-40   --不允许 VLAN10,20,30-40通过 Trunk口

2.3 PVLAN配置

  • 提问:如何实现几组用户之间的隔离,但同时又都能访问公用服务?
  • 回答:
    步骤一:创建隔离 VLAN
    S2724G#conf 
    S2724G(config)#vlan 3                        ---创建VLAN3 
    S2724G(config-vlan)#private-vlan community ---将VLAN3设为隔离VLAN
    S2724G(config)#vlan 4                     ---创建VLAN4 
    S2724G(config-vlan)#private-vlan community ---将VLAN4设为隔离VLAN
    S2724G(config-vlan)#exit                  ---退回到特权模式

    步骤二:创建主VLAN

    S2724G(config)#vlan 2                     ---进入VLAN2
    S2724G(config-vlan)#private-vlan primary  ---VLAN2为主VLAN

    步骤三:将隔离 VLAN加到到主 VLAN中

    VLANS2724G(config-vlan)#private-vlan association add 3-4   ---将 VLAN3和 VLAN4加入到公用 VLAN中, VLAN3和 VLAN4的用户可以访问公用接口

    步骤四:将实际的物理接口与VLAN相对应

    S2724G(config)#interface GigabitEthernet 0/1     ---进入接口1,该接口连接服务器或者上联设备
    S2724G(config-if)#switchport mode private-vlan promiscuous   ---接口模式为混杂模式
    S2724G(config-if)#switchport private-vlan mapping 2 add 3-4     ---将 VLAN3和 VLAN4映射到 VLAN2上
    S2724G(config)#int gi 0/10      ---进入接口 10
    S2724G(config-if)#switchport mode private-vlan host 
    S2724G(config-if)#switchport private-vlan host-association 2 3     ---该接口划分入VLAN3
    S2724G(config)#int gi 0/20      ---进入接口 20
    S2724G(config-if)#switchport mode private-vlan host 
    S2724G(config-if)#switchport private-vlan host-association 2 4   ---该接口划分入 VLAN4

    步骤五:完成 VLAN的映射

    S2724G(config)#int vlan 2              -进入VLAN2的SVI接口
    S2724G(config-if)#ip address 192.168.2.1 255.255.255.0    ---配置VLAN2的ip地址
    S2724G(config-if)#private-vlan mapping add 3-4    ---将VLAN3和VLAN4加入到VLAN2中
    注释:1. S20、S21不支持私有VLAN,可以通过保护端口实现类似功能 2. S3250、S3750和S5750同时支持保护端口和私有VLAN 3. S3760不支持私有VLAN和保护端口

2.4端口汇聚配置

  • 提问:如何将交换机的端口捆绑起来使用?
  • 回答:
    S5750#conf 
    S5750(config)#interface range gigabitEthernet 0/1 4  ---同时进入 1到 4号接口   
    S5750(config-if)#port-group 1      ---设置为聚合口1 
    S5750(config)#interface aggregateport 1        --进入聚合端口1 
    注意:配置为AP口的接口将丢失之前所有的属性,以后关于接口的操作只能在AP1口上面进行

2.5 生成树配置

  • 提问:如何配置交换机的生成树?
  • 回答:
    步骤一:根桥的设置
    switch_A#conf t
    switch_A(config)#spanning-tree     ---默认模式为 MSTP
    switch_A(config)#spanning-tree mst configuration
    switch_A(config)#spanning-tree mst 10 priority 4096 ---设置为根桥

    步骤二:非根桥的设置

    switch_B#conf t
    switch_B(config)#spanning-tree    ---默认模式为MSTP
    switch_B(config)#spanning-tree mst configuration
    switch_B(config)#int f0/1         ---PC的接入端口
    switch_B(config)#spanning-tree bpduguard enable
    switch_B(config)#spanning-tree portfast

2.6端口镜像配置

  • 提问:如何配置交换机的端口镜像?
  • 回答:
    switch#conf t 
    switch#(config)# 
    switch (config)# monitor session 1 source interface gigabitEthernet 3/1 both        ---监控源口为 g3/1                   
    switch (config)# monitor session 1 destination interface gigabitEthernet 3/8 switch    ---监控目的口为 g3/8,并开启交换功能    
    注意: S2026交换机镜像目的端口无法当做普通接口使用

第三章:交换机防止 ARP欺骗配置

3.1 交换机地址绑定( address-bind)功能

  • 提问:如何对用户 ip+mac进行两元素绑定?
  • 回答:
    S5750#conf
    S5750(config)# address-bind 192.168.0.101 0016.d390.6cc5   ----绑定 ip地址为 192.168.0.101 MAC地址为 0016.d390.6cc5的主机让其使用网络
    S5750(config)# address-bind uplink GigabitEthernet 0/1     ----将 g0/1口设置为上联口,也就是交换机通过 g0/1的接口连接到路由器或是出口设备,如果接口选择错误会导致整网不通.
    S5750(config)# address-bind install     ----使能address-bind功能
    S5750(config)#end      ----退回特权模式
    S5750# wr              ---保存配置
    注释:1. 如果修改ip或是MAC地址该主机则无法使用网络,可以按照此命令添加多条,添加的条数跟交换机的硬件资源有关 2. S21交换机的address-bind功能是防止Ip冲突,只有在交换机上绑定的才进行ip和MAC的匹配,如果下边用户设置的ip地址在交换机中没绑定,交换机不对该数据包做控制,直接转发。

3.2交换机端口安全功能

  • 提问:如何对用户ip+mac+接口进行三元素绑定?
  • 回答:
    S5750#conf 
    S5750(config)# int g0/23   ---进入第 23接口,准备在该接口绑定用户的 MAC和 ip地址
    S5750(config-if)# switchport port-security mac-address 0016.d390.6cc5 ip-address 192.168.0.101   ---在 23端口下绑定 ip地址是 192.168.0.101 MAC地址是 0016.d390.6cc5的主机,确保该主机可以正常使用网络,如果该主机修改 ip或者 MAC地址则无法使用网络,可以添加多条来实现对接入主机的控制    
    S5750(config-if)# switchport port-security  ---开启端口安全功能   S5750(config)#end                           ---退会特权模式
    S5750# wr                              ---保存配置
    注释:可以通过在接口下设置最大的安全地址个数从而来控制控制该接口下可使用的主机数,安全地址的个数跟交换机的硬件资源有关

    3.3 交换机 arp-check功能

  • 提问:如何防止错误的arp信息在网络里传播?
  • 回答:
    S5750#conf 
    S5750(config)# int g0/23    ---进入第23接口,准备在该接口绑定用户的MAC和ip地址
    S5750(config-if)# switchport port-security mac-address 0016.d390.6cc5 ip-address 192.168.0.101       ---ip+mac绑定信息  
    S5750(config-if)# switchport port-security   ---开启端口安全功能  S5750(config-if)# switchport port-security arp-check ---开启端 arp检查功能
    S5750(config)#end           ---退会特权模式
    S5750# wr                   ---保存配置
    注释:开启 arp-check功能后安全地址数减少一半,具体情况请查阅交换机配置指南

    3.4交换机ARP动态检测功能(DAI)

  • 提问:如何在动态环境下防止ARP欺骗?
  • 回答:
    步骤一: 配置 DHCP snooping
    S3760#con t 
    S3760(config)#ip dhcp snooping   ----开启 dhcp snooping S3760(config)#int f 0/1 
    S3760(config-if)#ip dhcp snooping trust  ---设置上连口为信任端口(注意: 缺省所有端口都是不信任端口) ,只有此接口连接的服务器发出的 DHCP响应报文才能够被转发. 
    S3760(config-if)#exit S3760(config)#int f 0/2 
    S3760(config-if)# ip dhcp snooping address-bind   ---配置 DHCP snooping的地址绑定功能
    S3760(config-if)#exit S3760(config)#int f 0/3 
    S3760(config-if)# ip dhcp snooping address-bind   ---配置DHCP snooping的地址绑定功能

    步骤二: 配置DAI

    S3760(config)# ip arp inspection   ---启用全局的DAI 
    S3760(config)# ip arp inspection vlan 2 -启用vlan2的DAI报文检查功能  S3760(config)# ip arp inspection vlan 3 -启用vlan3的DAI报文检查功能

第四章:访问控制列表配置( ACL) 4.1 标准 ACL配置

  • 提问:如何只允许端口下的用户只能访问特定的服务器网段?
  • 回答:

步骤一:定义 ACL

S5750#conf t        --进入全局配置模式
S5750(config)#ip access-list standard 1   --定义标准ACL
S5750(config-std-nacl)#permit 192.168.1.0 0.0.0.255     ----允许访问服务器资源
S5750(config-std-nacl)#deny any --拒绝访问其他任何资源
S5750(config-std-nacl)#exit  --退出标准 ACL配置模式

步骤二:将 ACL应用到接口上

S5750(config)#interface GigabitEthernet 0/1 --进入所需应用的端口   
S5750(config-if)#ip access-group 1 in -将标准 ACL应用到端口 in方向
注释:   
1. S1900系列、 S20系列交换机不支持基于硬件的 ACL。   
2. 实际配置时需注意,在交换机每个 ACL末尾都隐含着一条“拒绝所有数据流”的语句。   
3. 以上所有配置,均以锐捷网络 S5750-24GT/12SFP 软件版本 10.2( 2)为例。其他说明,其详见各产品的配置手册《访问控制列表配置》一节。

4.2 扩展 ACL配置

  • 提问:如何禁止用户访问单个网页服务器?
  • 回答:

步骤一:定义ACL

S5750#conf t        ---进入全局配置模式  
S5750(config)#ip access-list extended 100 --创建扩展ACL 
S5750(config-ext-nacl)#deny tcp any host 192.168.1.254 eq www  ---禁止访问web服务器  
S5750(config-ext-nacl)#deny tcp any any eq 135 ---预防冲击波病毒  
S5750(config-ext-nacl)#deny tcp any any eq 445   ---预防震荡波病毒  
S5750(config-ext-nacl)#permit ip any any ---允许访问其他任何资源  
S5750(config-ext-nacl)#exit   ---退出ACL配置模式  步骤二:将ACL应用到接口上
S5750(config)#interface GigabitEthernet 0/1 ----进入所需应用的端口
S5750(config-if)#ip access-group 100 in --将扩展 ACL应用到端口下

4.3 VLAN之间的 ACL配置

  • 提问:如何禁止VLAN间互相访问?
  • 回答:

步骤一:创建 vlan10、 vlan20、 vlan30

S5750#conf    --进入全局配置模式   
S5750(config)#vlan 10      --创建 VLAN10 
S5750(config-vlan)#exit   ---退出 VLAN配置模式
S5750(config)#vlan 20      --创建 VLAN20 
S5750(config-vlan)#exit    --退出 VLAN配置模式
S5750(config)#vlan 30     --创建 VLAN30 
S5750(config-vlan)#exit    --退出 VLAN配置模式

步骤二:将端口加入各自 vlan

S5750(config)# interface range gigabitEthernet 0/1-5   ---进入gigabitEthernet 0/1-5号端口   
S5750(config-if-range)#switchport access vlan 10  ---将端口加划分进vlan10 
S5750(config-if-range)#exit ---退出端口配置模式  
S5750(config)# interface range gigabitEthernet 0/6-10   ---进入gigabitEthernet 0/6-10号端口  
S5750(config-if-range)#switchport access vlan 20  ---将端口加划分进vlan20
S5750(config-if-range)#exit     ---退出端口配置模式  
S5750(config)# interface range gigabitEthernet 0/11-15  ---进入gigabitEthernet 0/11-15号端口   
S5750(config-if-range)#switchport access vlan 30 --将端口加划分进vlan30 S5750(config-if-range)#exit     --退出端口配置模式

步骤三:配置vlan10、vlan20、vlan30的网关IP地址

S5750(config)#interface vlan 10 --创建vlan10的SVI接口
S5750(config-if)#ip address 192.168.10.1 255.255.255.0  --配置VLAN10的网关
S5750(config-if)#exit     --退出端口配置模式  
S5750(config)#interface vlan 20 ---创建vlan10的SVI接口
S5750(config-if)#ip address 192.168.20.1 255.255.255.0 ---配置 VLAN10的网关
S5750(config-if)#exit   ---退出端口配置模式   
S5750(config)#interface vlan 30 --创建 vlan10的 SVI接口
S5750(config-if)#ip address 192.168.30.1 255.255.255.0  ---配置 VLAN10的网关
S5750(config-if)#exit  ---退出端口配置模式

步骤四:创建 ACL,使 vlan20能访问 vlan10,而 vlan30不能访问 vlan10

S5750(config)#ip access-list extended deny30  ---定义扩展 ACL 
S5750(config-ext-nacl)#deny ip 192.168.30.0 0.0.0.255 192.168.10.0 0.0.0.255   ----拒绝 vlan30的用户访问 vlan10资源
S5750(config-ext-nacl)#permit ip any any   ---允许vlan30的用户访问其他任何资源
S5750(config-ext-nacl)#exit   ---退出扩展ACL配置模式

步骤五:将ACL应用到vlan30的SVI口in方向

S5750(config)#interface vlan 30  --创建vlan30的SVI接口  S5750(config-if)#ip access-group deny30 in     ---将扩展ACL应用到vlan30的SVI接口下

4.4单向ACL的配置

  • 提问:如何实现主机A可以访问主机B的FTP资源,但主机B无法访问主机A的FTP资源??
  • 回答:
    步骤一:定义 ACL
    S5750#conf t     ---进入全局配置模式  
    S5750(config)#ip access-list extended 100   --定义扩展ACL 
    S5750(config-ext-nacl)#deny tcp any host 192.168.1.254 match-all syn  ---禁止主动向 A主机发起 TCP连接   
    S5750(config-ext-nacl)#permit ip any any ---允许访问其他任何资源   S5750(config-ext-nacl)#exit      --退出扩展 ACL配置模式 步骤二:将 ACL应用到接口上   
    S5750(config)#interface GigabitEthernet 0/1 --进入连接 B主机的端口   S5750(config-if)#ip access-group 100 in ---将扩展 ACL应用到端口下   S5750(config-if)#end       ---退回特权模式
    S5750#wr                     ----保存
    注释:单向 ACL只能对应于 TCP协议,使用 PING无法对该功能进行检测。

第五章:应用协议配置 5.1 DHCP服务配置

  • 提问:如何在设备上开启DHCP服务,让不同VLAN下的电脑获得相应的IP地址?
  • 回答:

步骤一:配置VLAN网关IP地址,及将相关端口划入相应的VLAN中

S3760#con t 
S3760(config)#vlan 2       --创建VLAN2 
S3760(config-vlan)#exit  --退回到全局配置模式下
S3760(config)#vlan 3     -创建VLAN3 
S3760(config-vlan)#exit  --退回到全局配置模式下
S3760(config)#int vlan 2  --进入配置VLAN2 
S3760(config-if)#ip add 192.168.2.1 255.255.255.0 --设置VLAN2的IP地址  S3760(config-if)#exit   ---退回到全局配置模式下
S3760(config)#int vlan 3 ----进入配置VLAN3 
S3760(config-if)#ip add 192.168.3.1 255.255.255.0 -设置 VLAN3的 IP地址   S3760(config-if)#exit       ---退回到全局配置模式下
S3760(config)#int f 0/2     --进入接口f0/2 
S3760(config-if)#switchport access vlan 2 --设置 f0/2口属于VLAN2S3760(config-if)#exit 
S3760(config)#int f 0/3         ---进入接口 f0/3 
S3760(config-if)#switchport access vlan 3 --设置 f0/3口属于 VLAN3 S3760(config-if)#exit

步骤二:配置 DHCP server

S3760 (config)#service dhcp  --开启 dhcp server功能
S3760 (config)#ip dhcp ping packets 1     ---在 dhcp server分配 IP时会先去检测将要分配的 IP地址是否已有人使用,如果没人使用则分配,若已有人使用则再分配下一个 IP 
S3760 (config)#ip dhcp excluded-address 192.168.2.1 192.168.2.10  ---设置排斥地址为 192.168.2.1至 192.168.2.10的 ip地址不分配给客户端(可选配置)
S3760 (config)#ip dhcp excluded-address 192.168.3.1 192.168.3.10  ---设置排斥地址为192.168.3.1至192.168.3.10的ip地址不分配给客户端(可选配置)
S3760 (config)#ip dhcp pool test2  ---新建一个dhcp地址池名为test2
S3760 (dhcp-config)# lease infinite  ---租期时间设置为永久
S3760 (dhcp-config)# network 192.168.2.0 255.255.255.0  ---给客户端分配的地址段  
S3760 (dhcp-config)# dns-server 202.101.115.55  ---给客户端分配的DNS S3760(dhcp-config)# default-router 192.168.2.1  --客户端的网关
S3760(dhcp-config)#exit 
S3760(config)#ip dhcp pool test3  ---新建一个 dhcp地址池名为 test3
S3760(dhcp-config)# lease infinite ---租期时间设置为永久
S3760(dhcp-config)# network 192.168.3.0 255.255.255.0
S3760(dhcp-config)# dns-server 202.101.115.55
S3760(dhcp-config)# default-router 192.168.3.1
S3760(dhcp-config)#end
S3760#wr

5.2 交换机 dot1x认证配置

  • 提问:如何在交换机上开启 dot1x认证?
  • 回答:
    步骤一:基本 AAA配置
    Switch#conf 
    Switch(config)# aaa new-model       ---启用认证   
    Switch(config)# aaa accounting network test start-stop group radius   ---配置身份认证方法   
    Switch(config)# aaa group server radius test   
    Switch(config-gs-radius)# server X.X.X.X  --指定记帐服务器地址   Switch(config-gs-radius)# exit 
    Switch(config)# aaa authentication dot1x default group radius local  ---配置dot1x认证方法  
    Switch(config)# radius-server host X.X.X.X -指定认证服务器地址  Switch(config)# radius-server key 0 password --指定radius共享口令  Switch(config)# dot1x accounting test --开启计帐功能  
    Switch(config)# dot1x authentication default --开启认证功能  
    Switch(config)# snmp-server community ruijie rw --指定SNMP共同体字段  Switch(config)# interface range fastethernet 0/1-24 --同时进1-24号接口  Switch(config-if-range)# dot1x port-control auto --指定受控端口  Switch(config-if-range)# exit  -退出接口模式

    步骤二:配置客户端探测功能

    Switch(config)# aaa accounting update --启用计帐更新
    Switch(config)# aaa accounting update periodic 5   ---指定计帐更新间隔为 5分钟   
    Switch(config)# dot1x client-probe enable --启用客户端在线探测功能   
    Switch(config)# dot1x probe-timer interval 20 --指定探测周期为 20秒   Switch(config)# dot1x probe-timer alive 60   --指定探测存活时间为 60秒

    步骤三: 配置记账更新功能

    Switch(config)# dot1x timeout quiet-period 5  ---指定认证失败等待时间   Switch(config)# dot1x timeout tx-period 3    ---指定交换机重传 Identity Requests报文时间
    Switch(config)# dot1x max-req 3     ---指定交换机重传 Identity Requests报文的最大次数
    Switch(config)# dot1x reauth-max 3    ---指定认证失败后交换机发起的重认证的最大次数
    Switch(config)# dot1x timeout server-timeout 5   ---指定认证服务器的响应超时时间   
    Switch(config)# dot1x timeout supp-timeout 3     ---指定认证客户端的响应超时时间   
    Switch(config)# dot1x private-supplicant-only   --过滤非锐捷客户端  Switch(config)# exit       --退出配置模式

    5.3 QOS限速配置

  • 提问:如何通过QOS实行限速?
  • 回答:
    步骤一:定义希望限速的主机范围
    S3760>en
    S3760#conf 
    S3760(config)#access-list 101 permit ip host 192.168.1.101 any       ----定义要限速的 IP 
    S3760(config)#access-list 102 permit ip host 192.168.1.102 any     ----定义要限速的IP

    步骤二:创建规则类,应用之前定义的主机范围

    S3760(config)#class-map xiansu101 --创建class-map,名字为xiansu101 S3760(config-cmap)#match access-group 101 --匹配IP地址
    S3760(config-cmap)#exit 
    S3760(config)#class-map xiansu102 创建 class-map,名字为 xiansu102
    S3760(config-cmap)#match access-group 102     --匹配 IP地址   S3760(config-cmap)#exit

    步骤三:创建策略类:应用之前定义的规则,配置限速大小

    S3760(config)#policy-map xiansu  --创建 policy-map,名字为 xiansu S3760(config-pmap)#class xiansu101   ---符合 class xiansu101 S3760(config-pmap-c)#police 8000 512 exceed-action drop   ---限速值为8000Kbit--符合 class xiansu102 
    S3760(config-pmap-c)#police 4000 512 exceed-action drop   ---限速值为 4000Kbit
    S3760(config-pmap-c)#end

    步骤四:进入接口,应用之前定义的策略

    S3760#conf 
    S3760(config)#int fa 0/10 
    S3760(config-if)#service-policy input xiansu  ---将该限速策略应用在这个接口上  注释:  
    1.通过QOS只能限制上行流量  
    2.推荐在S2924G,S3250和S3760上应用该功能

    5.4 IPsec配置

  • 提问:如何在两台路由器之间启用 IPsec?
  • 回答: R1路由器设置
    步骤一:配置访问控制列表,定义需要IPsec保护的数据
    R1(config)#access-list 101 permit ip host 1.1.1.1 host 1.1.1.2

    步骤二:定义安全联盟和密钥交换策略

    R1(config)#crypto isakmp policy 1 
    R1(isakmp-policy)#authentication pre-share --认证方式为预共享密钥
    R1(isakmp-policy)#hash md5      ---采用 MD5的 HASH算法

    步骤三:配置预共享密钥为 dixy,对端路由器地址为 1.1.1.2

    R1(config)#crypto isakmp key 0 dixy address 1.1.1.2

    步骤四:定义 IPsec的变换集,名字为 dixy

    R1(config)#crypto ipsec transform-set dixy ah-md5-hmac esp-des

    步骤五:配置加密映射,名字为 dixy

    R1(config)#crypto map dixy 1 ipsec-isakmp 
    R1(config-crypto-map)#set transform-set dixy --应用之前定义的变换集R1(config-crypto-map)#match address 101 --定义需要加密的数据流   
    R1(config-crypto-map)#set peer 1.1.1.2 ---设置对端路由器地址

    步骤六:在外网口上使用该加密映射

    R1(config-if)#crypto map dixy
    R1(config-if)#ip add 1.1.1.1 255.255.255.0

    R2路由器设置

R2路由器的设置和R1几乎是相似,只用红色字体标注出不一样的地方。

R2(config)#access-list 101 permit ip host 1.1.1.2 host 1.1.1.1
R2(config)#crypto isakmp policy 1 
R2(isakmp-policy)#authentication pre-share
R2(isakmp-policy)#hash md5 
R2(config)#crypto isakmp key 0 dixy address 1.1.1.1 
R2(config)#crypto ipsec transform-set dixy ah-md5-hmac esp-des R2(config)#crypto map dixy 1 ipsec-isakmp
R2(config-crypto-map)#
R2(config-if)#crypto map dixy
R2(config-if)#ip add 1.1.1.2 255.255.255.05.5

GRE配置

  • 提问:如何在两台路由器之间启用 GRE?
  • 回答:
    NBR(config)#interface Tunnel0 
    NBR(config-if)#ip address 1.1.1.1 255.255.255.0 
    NBR(config-if)#tunnel mode gre ip
    NBR(config-if)#tunnel source 10.1.1.1
    NBR(config-if)#tunnel destination 10.1.1.2 5.6

PPTP配置

  • 提问:如何在路由器上配置PPTP?
  • 回答:步骤一:配置VPN相关参数
    R1762#conf 
    R1762(config)#vpdn enable 
    R1762(config)#vpdn-group pptp  ---创建一个VPDN组,命名为pptp
    R1762(config-vpdn)#accept-dialin       ----允许拨号
    R1762(config-vpdn-acc-in)#protocol pptp -协议为 PPTP 
    R1762(config-vpdn-acc-in)#virtual-template 1  ---引用虚模板 1

    步骤二:配置用户和地址池

    R1762(config)#username test password 0 test         ----创建一个账户,用户和密码都是test 
    R1762(config)#ip local pool vpn 192.168.1.100 192.168.1.110 ---创建vpn拨入的地址池,命名为vpn,范围是192.168.1.100-110

    步骤三:配置虚拟模板

    R1762(config)#interface virtual-template 1   --创建虚模板1
    R1762(config-if)#ppp authentication pap      --加密方式为PAP
    R1762(config-if)#ip unnumbered fastEthernet 1/0 -关联内网接口   R1762(config-if)#peer default ip address pool vpn -引用地址范围   R1762(config-if)#ip nat inside --参与 NAT

    5.7 路由器 L2TP配置

  • 提问:如何在两台路由器之间构建 L2TP?
  • 回答: 步骤一: SERVER端路由器配置 VPN相关参数
    R1762#conf 
    R1762(config)#vpdn enable 
    R1762(config)#vpdn-group l2tp --创建一个VPDN组,命名为l2tp R1762(config-vpdn)#accept-dialin  ---允许拨号  
    R1762(config-vpdn-acc-in)#protocol l2tp -协议为l2tp 
    R1762(config-vpdn-acc-in)#virtual-template 1 -引用虚模板1

    步骤二:SERVER端路由器配置用户和地址池

    R1762(config)#username test password 0 test  ---创建一个账户,用户和密码都是test 
    R1762(config)#ip local pool vpn 192.168.1.100 192.168.1.110 ---创建vpn拨入的地址池,命名为vpn,范围是192.168.1.100-110

    步骤三:SERVER端路由器配置虚拟模板

    R1762(config)#interface virtual-template 1 --创建虚模板1 
    R1762(config-if)#ppp authentication chap   --加密方式为CHAP
    R1762(config-if)#ip unnumbered fastEthernet 1/0 --关联内网接口  R1762(config-if)#peer default ip address pool vpn -引用地址范围   R1762(config-if)#ip nat inside ---参与 NAT

    步骤四:Client端路由器VPN配置

    R1762(config)#l2tp-class l2tp -创建拨号模板,命名为l2tp
    R1762(config)#pseudowire-class vpn-l2tp --创建虚线路,命名为 vpn-l2tp 
    R1762(config-pw-class)#encapsulation l2tpv2 --封装 l2tpv2协议   R1762(config-pw-class)#protocol l2tpv2 l2tp    
    R1762(config-pw-class)#ip local interface 1/0 -关联路由器外网接口

    步骤五: Client路由创建虚拟拨号口

    R1762(config)#interface virtual-ppp 1  --创建虚拟 ppp接口   
    R1762(config)#pseudowire 192.168.33.39 11 encapsulation l2tpv2 pw-classvpn-l2tp ---L2TP服务器路由器的地址   
    R1762(config)#ppp chap hostname test     ----用户名
    R1762(config)# ppp chap password 0 test  ----密码
    R1762(config)# ip mtu 1460     
    R1762(config)# ip address negotiate     ---IP地址商议获取
    R1762(config)# ip nat outside  ---参与NAT

    5.8路由器NAT配置

  • 提问:如何设置NAT?
  • 回答:
    NBR(config)#access-list 10 permit 192.168.10.0 0.0.0.255   ---设置允许 NAT的地址范围   
    NBR(config)#interface FastEthernet 1/0 
    NBR(config-if)#ip nat outside  ---定义外网接口
    NBR(config)#interface FastEthernet 0/0 
    NBR(config-if)#ip nat inside  ----定义内网接口
    NBR(config)#ip nat pool defult prefix-length 24 --创建一个地址池,命名为defult 
    NBR(config-ipnat-pool)#address 208.10.34.2 208.10.34.7 match interface FastEthernet 1/0     ---公网地址范围为208.10.34.2到 208.10.34.7 
    NBR(config)#ip nat inside source list 10 pool test overload  ---应用地址池 

第六章:路由协议配置

6.1 默认路由配置

  • 提问:如何在设备上配置默认路由?
  • 回答:
    Ruijie#configure terminal   
    Ruijie (config)#ip route 0.0.0.0 0.0.0.0 fastEthernet 0/0 10.0.0.1     
    ----路由下一跳接口为 fa0/0,下一跳网关为 10.0.0.1

    6.2 静态路由配置

  • 提问:如何在设备上配置静态路由?
  • 回答:
    Ruijie#configure terminal   
    Ruijie (config)#ip route 192.168.1.0 255.255.255.0 fastEthernet 0/0 10.0.0.1  ----去往192.168.1.0网段的路由,下一跳接口为fa0/0,下一跳网关为10.0.0.1

    6.3浮动路由配置

  • 提问:如何在设备上配置浮动路由?
  • 回答:
    Ruijie#configure terminal   
    Ruijie (config)#ip route 0.0.0.0 0.0.0.0 fastEthernet 0/0 10.0.0.1
    Ruijie (config)#ip route 0.0.0.0 0.0.0.0 fastEthernet 1/0 20.0.0.1 90
    ----当 fa0/0出现问题后,所有路由由接口 fa1/0,送往网关 20.0.0.1 6.4 策略路由配置
  • 提问:希望部分IP走A线路,另一部分IP走B线路?
  • 回答:步骤一:配置匹配源的 ACL
    Ruijie#configure terminal   
    Ruijie (config)#access-list 1 permit 192.168.1.0 0.0.0.255-配置地址列表   Ruijie (config)#access-list 2 permit 192.168.2.0 0.0.0.255 -配置地址列表 

    步骤二 :配置 route-map

    Ruijie(config)#route-map test permit 10  --创建路由映射规则
    Ruijie(config-route-map)#match ip address 1  --符合地址列表 1 
    Ruijie(config-route-map)#set ip next-hop 1.1.1.1 --执行动作是送往 1.1.1.1 Ruijie(config-route-map)#exit 
    Ruijie(config)#route-map test permit 20          
    Ruijie(config-route-map)#match ip address 2   --符合地址列表 2 
    Ruijie(config-route-map)#set ip next-hop 2.2.2.1 --执行动作是送往2.2.2.1 Ruijie(config-route-map)#exit

    步骤三:在接口上应用route-map

    Ruijie config)#interface GigabitEthernet 0/0 --进入设备内网口  
    Ruijie(config-if)#ip address 192.168.1.1 255.255.255.0  --配置各个网段的ip地
    Ruijie(config-if)#ip address 192.168.2.1 255.255.255.0 secondary Ruijie(config-if)#ip policy route-map test --应用之前定义的路由映射  
    Ruijie(config-if)#exit
    注释:缺省情况下 route map的最后一句都是 deny all,这样不符合 route map规则的数据包都会按照正常的路由表进行转发。

    6.5 OSPF配置

  • 提问:在设备上启用 OSPF功能?
  • 回答:
    Ruijie#configure terminal    
    Ruijie(config)# router ospf 1 --OSPF进程号为 1,本地有效
    Ruijie(config-router)#network 0.0.0.0 255.255.255.255 area 0  --该设备上所有IP地址都参与到该OSPF进程中,进入area 0
    Ruijie(config-router)#exit
    Ruijie(config)#end
    注释:这里 OSPF 的进程号是本地使用,不需要像  EIGRP 一样整个网络保持一致。

    6.6 OSPF中 router ID配置

  • 提问:如何手工配置 router ID?
  • 回答:
    Ruijie(config)# router ospf 1 
    Ruijie(config-router)#Router-id 100.100.100.100 
    Change router-id and update OSPF process! [yes/no]:y 
    注释:设备缺省会用使用最大 IP地址的环回口地址为 RID,如果没有环回口则启用最大  IP
    地址的物理口作为Router ID。手工配置的Router ID命令后面的 IP地址可以随意,不需 
    要必须是存在的地址。另外 Router ID一旦定下来以后,即使重新修改了接口地址也不会 
    使其变更,必须通过clear ip ospf process的方式或者reload的方式来改变.