定时关闭华为交换机的端口

关于因业务须求,定时关闭交换机的端口的做法       通过对各种资料的查询与对比,我现在知道了两种可以实现在某一特定时间内关闭交换机端口,并在另一时间段打开端口的做法。现我将其做法与大家分享一下。希望大家提出好的意见。(以S8500设备为例)
      一。通过做ACL规则开限开关端口(其时也不叫开开关端口,只是通过规则禁止端口数据的访问)
      time ShiJian 00:00 to 08:00 dai (指定时间段为00:00到08:00)
      再做一个ACL规则。再在ACL下面引用上面的时间,
      最后在端口上,引用这个ACL规则      (这一方法的缺点:步骤太多,必须确定到端口的用户IP,且要单个引用,否则会引起某些端口无法限制。)
      二。通过在电脑里运行BAT文件。直接关闭用户端口或开启用户端口
      其方法如下      1.关闭交换机端口.BAT      echo set sh=WScript.CreateObject("WScript.Shell") >>telnet_tmp.vbs
     echo WScript.Sleep 1000 >> telnet_tmp.vbs                                   (生成临时文件telnet_tmp.vbs并打开TELNET窗口)
     echo sh.SendKeys "open 111.111.111.123" >>telnet_tmp.vbs          (telnet 到 111.111.111.123 交换机)
     echo sh.SendKeys "{ENTER}" >>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs                                    (单步延时1秒)
     echo sh.SendKeys "XXXXX-XXXX{ENTER}" >>telnet_tmp.vbs              (输入登录用户名:XXXXX-XXXX)
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "XXXXX-XXXX{ENTER}">>telnet_tmp.vbs               (输入登录密码:XXXXX-XXXX)
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "sys{ENTER}">>telnet_tmp.vbs                            (进入交换机配置模式)
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/1 {ENTER}">>telnet_tmp.vbs           (进入交换机端口)
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs                    (shutdown这个交换端口)
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/2 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/3 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/5 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/6 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/7 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/8 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/10 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/13 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     start telnet
     cscript //nologo telnet_tmp.vbs
     del telnet_tmp.vbs      2.开启交换机端口.BAT      echo set sh=WScript.CreateObject("WScript.Shell") >>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "open 111.111.111.123" >>telnet_tmp.vbs
     echo sh.SendKeys "{ENTER}" >>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "XXXXX-XXXX{ENTER}" >>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "XXXXX-XXXX{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "sys{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/1 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/2 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/3 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo  shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/5 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/6 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/7 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/8 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/10 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "interface ethernet 2/1/13 {ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "undo shutdown{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "{ENTER}">>telnet_tmp.vbs
     echo WScript.Sleep 1000 >>telnet_tmp.vbs
     echo sh.SendKeys "quit{ENTER}">>telnet_tmp.vbs
     start telnet
     cscript //nologo telnet_tmp.vbs
     del telnet_tmp.vbs     将这两个文件放在一台可以直接TELNET交换机的电脑上,然后在运行这台电脑的任务计划,将这两个文件引入,并指定相关的时间段。(这样就OK了)
    (此方法的优点:可以一次性解决关闭端口的问题,设置完成后,无须人为干预,定时准确,关闭端口彻底。100%阻断用户上网)
    (此方法的缺点:对管理员编程要求高。特别是会BAT编程,其次,必须要有一台可直接TELNET交换机的电脑,且必须开机。)
更多:http://www.killtest.cn/H3COthersCertification/  
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值