神州数码路由交换命令.docx
《神州数码路由交换命令.docx》由会员分享,可在线阅读,更多相关《神州数码路由交换命令.docx(13页珍藏版)》请在冰豆网上搜索。
神州数码路由交换命令
特别注意
交换机恢复出厂:
setdfaultwritereload
firewallenable #全局开启firewallenable
firewalldefault{permit|deny}设置防火墙默认动作
跟踪路由tracert
Telnet,SSH远程登录
路由器
aaaauthenticationlogindefaultlocal
aaaauthenticationenabledefaultenable
usernameabcpassword123
enablepassword0123
linevty0
loginauthenticationdefault
交换机
Switch(config)#telnet-serverenable
Switch(config)#usernametestprivilege15password0test
Switch(config)#authenticationlinevtyloginlocal
authenticationsecurityip配置Telnet登录到交换机的安全IP地址
限制允许IP地址段Telnet登录交换机
switch(config)#access-list1permit192.168.1.00.0.0.255
switch(config)#authenticationipaccess-class1in
Switch(config)#ssh-serverenable
Switch(config)#usernametestprivilege15password0test
Switch(config)#authenticationlinevtyloginlocal
Switch(config)#interfacevlan1
Switch(Config-if-Vlan1)#ipaddress100.100.100.200255.255.255.0
ssh-servertimeout设置SSH认证超时时间
ssh-serverauthentication-retries设置SSH认证重试次数
switch(config)#iphttpserver
switch(config)#usernametestprivilege15password0test
switch(config)#authenticationline webloginlocal
switch(config)#iphttpsecure-server
DHCP
switch(config)#servicedhcp
switch(config)#ipdhcppoolvlan10
switch(dhcp-vlan10-config)#network10.1.1.124
switch(dhcp-vlan10-config)#default-router10.1.1.1
中继:
switch(config)#servicedhcp
switch(config)#ipforward-protocoludpbootps
switch(config-Vlan20)#iphelp-address10.1.1.1
dhcp绑定,不允许手动配置ip地址
#全局开启DHCPSnooping和DHCPSnooping绑定功能
DHCP分配固定ip:
switch(config)#ipdhcpexcluded-address10.1.1.210.1.1.10不自动分配地址池
switch(config)#ipdhcppool10
switch(dhcp-vlan10-config)#host10.1.1.5
switch(dhcp-vlan10-config)#default-router10.1.1.1
switch(dhcp-vlan10-config)#hardware-address00-0B-4C-9E-2a-1C绑定硬件地址
#全局开启DHCPSnooping和DHCPSnooping绑定功能
switch(config)#ipdhcpsnoopingenable
switch(config)#ipdhcpsnoopingbindingenable
switch(config)#interfaceethernet1/24
switch(Config-Ethernet1/24)#ipdhcpsnoopingtrust
#设置E1/1端口可以自动绑定DHCP获得的IP地址
switch(config)#interfaceethernet1/1
switch(Config-Ethernet1/1)#ipdhcpsnooping bindinguser-control
switch(Config-Ethernet1/1)#exit
#手动绑定PC1的IP地址和MAC地址
switch(config)#ipdhcpsnoopingbindinguser00-11-11-11-11-11address10.1.1.2mask255.255.255.0vlan1interface1/2
路由器:
Router_config#ip dhcpd enable //启动DHCP 服务
Router_config#ip dhcpd pool 1
Router_config_dhcp#network 192.168.1.0 255.255.255.0
Router_config_dhcp#range 192.168.1.11 192.168.1.20
Router_config_dhcp#lease 1 //定义租期
Router_config_dhcp#dns-server 1.1.1.1 //定义DNS服务器地址
Router_config_dhcp#default-router 192.168.1.1
端口安全
Switchportport-securitylock锁定安全端口,使pc只能通过此端口通信
Switchportport-securityconvert动态学习mac
Mac-address-tableblackholeaddressaa-bb-cc-dd-ee-ffvlan30mac表过滤
端口操作
端口IPmac绑定
#全局打开AM功能
Switch(config)#amenable
#端口1/1开启AM功能,绑定IP
Switch(config)#interfaceethernet1/1
Switch(config-If-Ethernet1/1)#amport
Switch(config-If-Ethernet1/1)#amip-pool 1.1.1.2 2
Switch(config-If-Ethernet1/1)#exit
#端口1/2开户AM功能,绑定IP、MAC
Switch(config)#interfaceethernet1/2
Switch(config-If-Ethernet1/2)#amport
Switch(config-If-Ethernet1/2)#ammac-ip-pool00-44-44-44-44-441.1.1.4
Switch(config-If-Ethernet1/2)#exit
端口限速
Switch(config)#interfaceethernet1/1
Switch(Config-If-Ethernet1/1)#bandwidthcontrol 10000both限速10MB
参数:
both为端口收发时均进行带宽控制;receive为仅在端口接收数据时进行带宽控制;transmit为仅在端口发送数据时进行带宽控制。
rate-violation<200-2000000>设置交换机端口的报文最大收包速率,如果端口的接收报文速率违背了收包速率则shutdown端口,可以配置shutdown端口后的恢复时间,默认是300s。
端口镜像
Monitorsession1sourceinterfacee0/1rx被复制端口的RX数据(RX(收)TX(发)both(所有))
Monitorsession1destinationinterfacee0/24复制到端口,目地端口只能是1个端口
switch(config)#monitorsession1reflector-portinterfaceethernet1/3镜像端口
端口隔离
#配置端口E0/0/1和E0/0/2属于隔离组test
Switch(config)#isolate-portgrouptestswitchportinterfaceethernet 0/0/1-2
SW3的配置
单端口环路检测
#全局配置单端口环路检测报文的发送间隔(有环路时120秒发送1次,没有环路时2秒发送1次)
switch(config)#loopback-detectioninterval-time3515
#端口打开单端口环路检测功能,控制模式为ShutDown
switch(config)#interfaceethernet1/1-24
switch(config-if-port-range)#loopback-detectionspecial-vlan1
switch(config-if-port-range)#loopback-detectioncontrolshutdown
switch(config-if-port-range)#exit
#全局打开单端口环路ShutDown自动恢复功能,恢复时间为300秒
switch(config)#loopback-detectioncontrol-recoverytimeout300
VRRP
交换机:
switch(config)#routervrrp10
switch(config-router)#virtual-ip 192.168.10.254
switch(config-router)#priority 120
switch(config-router)#interfacevlan10
switch(config-router)#circuit-failovervlan200110跟踪上联接口
switch(config-router)#enable
路由器:
RouterA_config#interfacefastEthernet0/0.2!
进入子端口F0/0.2
RouterA_config_f0/0.2#ipaddress192.168.0.20255.255.255.0!
配置F0/0.2子端口的IP
RouterA_config_f0/0.2#encapsulationdot1Q2!
设置端口封装vlan2(vlan2从这里过)
RouterA_config_f0/0.2#vrrp2associate192.168.0.2255.255.255.0!
配置VRRP组2的虚拟IP
RouterA_config_f0/0.2#vrrp2priority105!
配置VRRP组2的优先级为105
RouterA_config_f0/0.2#vrrp2preempt(默认为抢占模式,不设置也行)!
配置VRRP组2为抢占模式
RouterA_config_f0/0.2#vrrp2trackinterfacefastEthernet0/310!
配置VRRP组2跟踪外网接口F0/3当外网接口中断时优先级减10
组播路由协议
路由
全局模式:
Ipmulticast-routing
端口下:
ipdvmrp
交换
每个接口下应用:
ipdvmrpenable
全局模式:
ipdvmrpmulticast-routing
每个接口下应用:
ippimmulticast-routing
端口下:
ippimdense-mode
ACL
switch(config)#firewallenable #开局开户firewallenable
switch(config)#mac-access-listextendednoaccess_00-03-0f-00-00-02 #创建ACL
switch(config-mac-ext-nacl-noaccess_00-03-0f-00-00-02)#denyhost-source-mac00-03-0f-00-00-01host-destination-mac00-03-0f-00-00-02 #拒绝MAC00-03-0f-00-00-01访问00-03-0f-00-00-02
switch(config-if-ethernet1/0/1)#macaccess-groupnoaccess_00-03-0f-00-00-01in #接口下调用
switch(config)#firewallenable #全局开启firewallenable
switch(config)#access-list3222deny00-03-0f-00-00-0100-00-00-00-00-ffany-destination-mactcp192.168.1.00.0.0.255any-destinationd-port23 #匹配网段、MAC、端口等
switch(config-if-ethernet1/0/1)#mac-ipaccess-group3222in #在接口下调用ACL
配置IP的扩展acl_b,任何时间仅允许访问同一网段(如192.168.1.255)内的主机。
Switch(config)#ipaccess-listextendedvacl_b
Switch(config-ip-ext-nacl-vacl_a)#permitipany-source192.168.1.00.0.0.255
Switch(config-ip-ext-nacl-vacl_a)#denyipany-sourceany-destination
Switch(config)#vaclipaccess-groupvacl_binvlan2将配置应用到VLAN。
ARP攻击防护
#开启ARP-Guard功能,防止PC机发出网关欺骗报文
Switch(config)#interfaceethernet1/1
Switch(Config-If-Ethernet1/1)#arp-guardip192.168.10.1
Switch(config)#exit
Switch(config)#interfaceethernet1/2
Switch(Config-If-Ethernet1/2)#arp-guardip192.168.20.1
#开启Anti-ArpScan功能,防止PC机发出大量ARP影响其他PC
Switch(config)#anti-arpscanenable启动防ARP扫描
Switch(config)#anti-arpscanportbasedthreshold自每秒端口ARP上限30
Switch(config)#anti-arpscanrecoveryenable开启防扫描自动恢复功能
Switch(config)#anti-arpscanrecoverytime3600自动恢复时间
Switch(config)#interfaceethernet1/24
Switch(config-If-Ethernet1/24)#anti-arpscantrustsupertrust-port配置为信任端口
Switch(config-If-Ethernet1/24)#exit
#针对静态IP用户,使用AM功能防止PC机发出主机欺骗报文。
针对动态IP用户,使用DHCPSnoopingBinding功能防止PC机发出主机欺骗报文。
NTP时间服务
Switch(config)#sntpserver1.1.1.10#交换机上配置SNTP服务器地址
Switch(config)#ntpenable#交换机上使能NTP功能,并配置NTP服务器地址
Switch(config)#ntpserver1.1.1.10
Clocktimezonebeijing8配置中国时区
Clockset15:
30:
00aug22014配置时间(特权模式下)
RIP认证(MD5)
路由器:
ipripauthenticationmessage-digest
ipripauthentication-key1md5123组编号1,密码123
交换机:
SWA(config)#keychinaname(key名称)
SWA(config-keychain)#key1(编号)
SWA(config-keychain-key)#key-string123(密码)
控制管理距离Distance
Distance125(修改后)0.0.0.0255.255.255.255(路由更新源)10(被ACL匹配的路由)
偏移列表(offset-list)
用于在入口或出口增大通过RIP获悉流量度量值
Router(config-router)#offset-listACL编号in/out2(增加量)f0/0(接口)
修改管理ospf管理距离
Router(config-router)#distance120(新AD值)0.0.0.025.5.255.25510(ACL匹配的路由)
分发列表distribute-list
R2(config)#access-list1deny192.168.3.0
R2(config)#access-list1permitany
R2(config)#routerrip
R2(config-router)# distribute-list1infa0/0
分发列表是用于控制路由更新的一个工具,只能过滤路由信息,不能过滤LSA。
因此:
分发列表在距离矢量路由协议中使用,无论是in或者是out方向,都能正常的过滤路由。
但是在链路状态路由协议中的工作就有点问题了。
Filter
R2(config)#access-list1permitany
R2(config-router)#filters1/0inaccess-list1在s1/0入口处,符合acl的网络可以通过ospf进行更新
策略路由
路由器
Router-A_config#ipaccess-liststandardnet1!
定义ACL
Router-A_config_std_nacl#permit192.168.0.10255.255.255.255
!
设置需要进行策略路由的源地址
Router-A_config_std_nacl#exit
Router-A_config#route-mappbr10permit!
定义route-map
Router-A_config_route_map#matchipaddressnet1!
设定源地址
Router-A_config_route_map#setipnext-hop192.168.1.2!
设置下一跳地址
Router-A_config_route_map#exit
Router-A_config_s1/1#intf0/0!
进入源地址的路由器接口
Router-A_config_f0/0#ippolicyroute-mappbr!
绑定route-map
交换机
switch(config)#ipaccess-listextendedTo_10 #新建ACL
switch(config-ip-ext-nacl-to_10)#permitip192.168.1.00.0.0.255192.168.10.00.0.0.255
switch(config-ip-ext-nacl-to_10)#denyipany-sourceany-destination #匹配网段
switch(config)#class-mapTo_10
switch(config-classmap-to_10)#matchaccess-groupTo_10 #定义classmap调用ACL
switch(config)#policy-mapTo_10
switch(config-policymap-to_10)#classTo_10 #定义policymap,调用classmap
switch(config-policymap-to_10-class-to_10)#setipnexthop10.1.1.1 #指下一跳
switch(config)#interfaceethernet1/0/1
switch(config-if-ethernet1/0/1)#service-policyinputTo_10 #在接口下调用
QOS
QOS限制带宽
将来自192.168.1.0网段目的为192.168.10.0的流量下一跳指到10.1.1.1,其它流量不做策略路由。
switch(config)#ipaccess-liststandardcir_tenM_cbs_fourM #新建ACL
switch(config-ip-std-nacl-cir_tenM_cbs_fourM)#permit192.168.1.00.0.0.255
switch(config-ip-std-nacl-cir_tenM_cbs_fourM)#denyany-source #匹配网段
switch(config)#class-mapcir_tenM_cbs_fourM
switch(config-classmap-cir_tenm_cbs_fourm)#matchaccess-groupcir_tenM_cbs_fourM #新建classmap调用ACL
sw