[Visual Basic] 纯文本查看 复制代码
#$language = "VBScript"
#$interface = "1.0"
'by lixiang
crt.Screen.Synchronous = True
Sub Main
crt.Screen.Send "sys"&chr(13)& "dis version"&chr(13)
If (crt.Screen.WaitForString("Version 7",3) <> False)Then
MsgBox("H3C设备,系统版本V7")
crt.Screen.Send " "& chr(13)
'基本配置
crt.Screen.Send "vlan 2 to 4094"& chr(13)
crt.Screen.WaitForString "]"
crt.Screen.Send " "& chr(13)&"sysname "& InputBox("1-64个字符,貌似支持中文","输入设备名称","123") & chr(13)
crt.Sleep 3000'等待ms
crt.Screen.Send "undo interface Vlan-interface 1"& chr(13)
crt.Screen.Send " "& chr(13)&"interface Vlan-interface "& InputBox("vlan 1-4094","输入管理vlan","4094") & chr(13)
crt.Screen.Send " "& chr(13)&"ip address "& InputBox("IP+掩码","输入管理地址","127.0.0.1 255.255.225.0") & chr(13)& "quit"& chr(13)
crt.Screen.Send " "& chr(13)&" ip route-static "& InputBox("缺省路由","缺省路由","0.0.0.0 0.0.0.0 127.0.0.254") & chr(13)& chr(13)
crt.Sleep 1000'等待ms
'开启snmp
crt.Screen.Send "snmp-agent"&chr(13)
crt.Screen.Send "snmp-agent community read AAAA"&chr(13)
crt.Screen.Send "snmp-agent community write AAAA"&chr(13)
crt.Screen.Send "snmp-agent sys-info version all"&chr(13)
crt.Screen.Send "snmp-agent target-host trap address udp-domain 127.0.0.1 params securityname AAAA v2c"&chr(13)
crt.Screen.Send "snmp-agent target-host trap address udp-domain 127.0.0.1 params securityname AAAA"&chr(13)
'远程acl
crt.Screen.Send "acl number AAAA"&chr(13)
crt.Screen.Send "rule 0 permit source 127.0.0.1 0"&chr(13)
crt.Screen.Send "rule 100 deny"&chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "telnet server acl AAAA"&chr(13)
'域
crt.Screen.Send "radius scheme cams"&chr(13)
crt.Screen.Send "primary authentication 127.0.0.1"&chr(13)
crt.Screen.Send "primary accounting 127.0.0.1"&chr(13)
crt.Screen.Send "accounting-on enable"&chr(13)
crt.Screen.Send "key authentication cipher AAAA"&chr(13)
crt.Screen.Send "key accounting cipher AAAA"&chr(13)
crt.Screen.Send "retry stop-accounting 10"&chr(13)
crt.Screen.Send "radius scheme AAAA"&chr(13)
crt.Screen.Send "user-name-format without-domain"&chr(13)
crt.Screen.Send "domain AAAA"&chr(13)
crt.Screen.Send "authentication default radius-scheme cams"&chr(13)
crt.Screen.Send "authorization default radius-scheme cams"&chr(13)
crt.Screen.Send "accounting default radius-scheme cams"&chr(13)
crt.Screen.Send "domain AAAA"&chr(13)
crt.Screen.Send "domain default enable AAAA"&chr(13)
'登录
crt.Screen.Send "local-user AAAA"&chr(13)
crt.Screen.Send "password simple AAAA"&chr(13)
crt.Screen.Send "authorization-attribute user-role network-admin"&chr(13)
crt.Screen.Send "service-type ssh terminal "&chr(13)
crt.Screen.Send "ssh server enable"&chr(13)
crt.Screen.Send "ssh server enable"&chr(13)
crt.Screen.Send "ssh user AAAA service-type stelnet authentication-type password"&chr(13)
crt.Screen.Send "user-interface aux 0"&chr(13)
crt.Screen.Send " "& chr(13)&"set authentication password simple "& InputBox("","输入console密码","AAAA") & chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "user-interface vty 0 63"&chr(13)
crt.Screen.Send "acl AAAA inbound"&chr(13)
crt.Screen.Send "protocol inbound all"&chr(13)
crt.Screen.Send "authentication-mode scheme"&chr(13)
crt.Screen.Send "user-role network-admin"&chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "public-key local create rsa"&chr(13)
crt.Screen.Send "y"&chr(13)&chr(13)
crt.Sleep 3000
crt.Screen.Send "public-key local create rsa"&chr(13)
crt.Screen.Send "public-key local create dsa"&chr(13)&chr(13)
crt.Sleep 3000
MsgBox("下面进行access端口配置")
crt.Screen.Send " "& chr(13)&"interface range "& InputBox("输入要批量配置的端口Ethernet& GigabitEth","access端口","Gigabi 1/0/1 to Gigabi 1/0/6") & chr(13)
crt.Screen.Send " "& chr(13)&"port access vlan "& InputBox("access vlan","access 端口vlan","2") & chr(13)
crt.Screen.Send "stp edged-port enable"&chr(13)
crt.Screen.Send "stp edged-port" & chr(13)
crt.Screen.Send "quit"&chr(13)
MsgBox("下面进行trunk端口配置")
crt.Screen.Send " "& chr(13)&"interface range "& InputBox("输入要批量配置的端口Ethernet& GigabitEth interface range","trunk端口","GigabitEth 1/0/7 to GigabitEth 1/0/10") & chr(13)
crt.Screen.Send " "& chr(13)&"port link-type trunk"& chr(13) &InputBox("trunk端口","端口vlan","port trunk permit vlan all") & chr(13)
crt.Screen.Send "dhcp snooping trust"&chr(13)
crt.Screen.Send "dhcp-snooping trust" & chr(13)
crt.Screen.WaitForString "]"
crt.Screen.Send "quit"&chr(13)
Else
crt.Screen.Send "sys"&chr(13)& "dis version"&chr(13)
If (crt.Screen.WaitForStrings("Version 5",3) <> False)Then
MsgBox("H3C设备,系统版本V5")
crt.Screen.Send " "& chr(13)
'基本配置
crt.Screen.Send "vlan 2 to 4094"& chr(13)
crt.Screen.Send " "& chr(13)
crt.Screen.WaitForString "]"
crt.Screen.Send " "& chr(13)&"sysname "& InputBox("1-64个字符,貌似支持中文","输入设备名称","123") & chr(13)
crt.Sleep 3000'等待ms
crt.Screen.Send "undo interface Vlan-interface 1"& chr(13)
crt.Screen.Send " "& chr(13)&"interface Vlan-interface "& InputBox("vlan 1-4094","输入管理vlan","4094") & chr(13)
crt.Screen.Send " "& chr(13)&"ip address "& InputBox("IP+掩码","输入管理地址","127.0.0.1 255.255.255.0") & chr(13)& "quit"& chr(13)
crt.Screen.Send " "& chr(13)&" ip route-static "& InputBox("缺省路由","缺省路由","0.0.0.0 0.0.0.0 127.0.0.1") & chr(13)& chr(13)
crt.Sleep 1000'等待ms
'开启snmp
crt.Screen.Send "snmp-agent"&chr(13)
crt.Screen.Send " snmp-agent community read AAAA"&chr(13)
crt.Screen.Send "snmp-agent community write AAAA"&chr(13)
crt.Screen.Send "snmp-agent sys-info version all"&chr(13)
crt.Screen.Send "snmp-agent target-host trap address udp-domain 127.0.0.1 params securityname AAAA"&chr(13)
crt.Screen.Send "snmp-agent target-host trap address udp-domain 127.0.0.1 params securityname AAAA"&chr(13)
'远程acl
crt.Screen.Send "acl number AAAA"&chr(13)
crt.Screen.Send "rule 0 permit source 127.0.0.1 0"&chr(13)
crt.Screen.Send "rule 100 deny"&chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "telnet server acl AAAA"&chr(13)
'域
crt.Screen.Send "radius scheme cams"&chr(13)
crt.Screen.Send "primary authentication 127.0.0.1"&chr(13)
crt.Screen.Send "primary accounting 127.0.0.1"&chr(13)
crt.Screen.Send "accounting-on enable"&chr(13)
crt.Screen.Send "key authentication cipher AAAA"&chr(13)
crt.Screen.Send "key accounting cipher AAAA"&chr(13)
crt.Screen.Send "retry stop-accounting 10"&chr(13)
crt.Screen.Send "radius scheme AAAA"&chr(13)
crt.Screen.Send "user-name-format without-domain"&chr(13)
crt.Screen.Send "domain AAAA"&chr(13)
crt.Screen.Send "authentication default radius-scheme cams"&chr(13)
crt.Screen.Send "authorization default radius-scheme cams"&chr(13)
crt.Screen.Send "accounting default radius-scheme cams"&chr(13)
crt.Screen.Send "domain AAAA"&chr(13)
crt.Screen.Send "domain default enable AAAA"&chr(13)
'登录
crt.Screen.Send "local-user AAAA"&chr(13)
crt.Screen.Send "password simple AAAA"&chr(13)
crt.Screen.Send "authorization-attribute user-role guest-manager level 3"&chr(13)
crt.Screen.Send "service-type ssh terminal "&chr(13)
crt.Screen.Send "ssh server enable"&chr(13)
crt.Screen.Send "ssh server enable"&chr(13)
crt.Screen.Send "ssh user AAAA service-type stelnet authentication-type password"&chr(13)
crt.Screen.Send "user-interface aux 0"&chr(13)
crt.Screen.Send " "& chr(13)&"set authentication password simple "& InputBox("","输入console密码","AAAA") & chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "user-interface vty 0 15"&chr(13)
crt.Screen.Send "acl AAAA inbound"&chr(13)
crt.Screen.Send "protocol inbound all"&chr(13)
crt.Screen.Send "user privilege level 3 "&chr(13)
crt.Screen.Send "authentication-mode scheme "&chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "public-key local create rsa"&chr(13)
crt.Screen.Send "y"&chr(13)&chr(13)
crt.Sleep 3000
crt.Screen.Send "public-key local create rsa"&chr(13)
crt.Screen.Send "public-key local create dsa"&chr(13)&chr(13)
crt.Sleep 3000
'MsgBox("下面进行access端口配置")
crt.Screen.Send " "& chr(13)&"interface range "& InputBox("输入要批量配置的端口Ethernet& GigabitEth","access端口","Ethernet 1/0/1 to Ethernet 1/0/8") & chr(13)
crt.Screen.Send " "& chr(13)&"port access vlan "& InputBox("access vlan","access 端口vlan","100") & chr(13)
crt.Screen.Send "quit"&chr(13)
'MsgBox("下面进行trunk端口配置")
crt.Screen.Send " "& chr(13)&"interface range "& InputBox("输入要批量配置的端口Ethernet& GigabitEth interface range","trunk端口","GigabitEth 1/0/9 to GigabitEth 1/0/9") & chr(13)
crt.Screen.Send " "& chr(13)&"port link-type trunk"& chr(13) &InputBox("trunk端口","端口vlan","port trunk permit vlan all") & chr(13)
crt.Screen.Send "dhcp snooping trust"&chr(13)
crt.Screen.Send "dhcp-snooping trust" & chr(13)
crt.Screen.WaitForString "]"
crt.Screen.Send "quit"&chr(13)
Else
crt.Screen.Send "sys"&chr(13)& "dis version"&chr(13)
If (crt.Screen.WaitForStrings("Version 3",3) <> False)Then
MsgBox("H3C设备,系统版本V3")
crt.Screen.Send " "& chr(13)&"sysname "& InputBox("H3C设备系统版本3,1-64个字符,不支持中文","输入设备名称","123") & chr(13)
crt.Screen.Send " "& chr(13)
'基本配置
crt.Screen.Send "vlan 2 to 4094"& chr(13)
crt.Sleep 3000
crt.Screen.Send " "& chr(13)
crt.Screen.WaitForString "]"
crt.Screen.Send " "& chr(13)&"sysname "& InputBox("1-64个字符,貌似支持中文","输入设备名称","123") & chr(13)
crt.Sleep 3000'等待ms
crt.Screen.Send "undo interface Vlan-interface 1"& chr(13)
crt.Screen.Send " "& chr(13)&"interface Vlan-interface "& InputBox("vlan 1-4094","输入管理vlan","4094") & chr(13)
crt.Screen.Send " "& chr(13)&"ip address "& InputBox("IP+掩码","输入管理地址","172.18.0.1 255.255.255.0") & chr(13)& "quit"& chr(13)
crt.Screen.Send " "& chr(13)&" ip route-static "& InputBox("缺省路由","缺省路由","0.0.0.0 0.0.0.0 172.18.0.254") & chr(13)& chr(13)
crt.Sleep 1000'等待ms
'开启snmp
crt.Screen.Send "snmp-agent"&chr(13)
crt.Screen.Send " snmp-agent community read AAAA"&chr(13)
crt.Screen.Send "snmp-agent community write AAAA"&chr(13)
crt.Screen.Send "snmp-agent sys-info version all"&chr(13)
crt.Screen.Send "snmp-agent target-host trap address udp-domain 127.0.0.1 params securityname AAAA"&chr(13)
crt.Screen.Send "snmp-agent target-host trap address udp-domain 127.0.0.1 params securityname AAAA"&chr(13)
'远程acl
crt.Screen.Send "acl number AAAA"&chr(13)
crt.Screen.Send "rule 0 permit source 127.0.0.1 0"&chr(13)
crt.Screen.Send "rule 100 deny"&chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "telnet server acl AAAA"&chr(13)
'域
crt.Screen.Send "radius scheme cams"&chr(13)
crt.Screen.Send "primary authentication 127.0.0.1"&chr(13)
crt.Screen.Send "primary accounting 127.0.0.1"&chr(13)
crt.Screen.Send "accounting-on enable"&chr(13)
crt.Screen.Send "key authentication AAAA"&chr(13)
crt.Screen.Send "key accounting AAAA"&chr(13)
crt.Screen.Send "retry stop-accounting 10"&chr(13)
crt.Screen.Send "radius scheme AAAA"&chr(13)
crt.Screen.Send "user-name-format without-domain"&chr(13)
crt.Screen.Send "domain AAAA"&chr(13)
crt.Screen.Send "authentication radius-scheme cams"&chr(13)
crt.Screen.Send "authorization hwtacacs-scheme cams"&chr(13)
crt.Screen.Send "accounting radius-scheme cams"&chr(13)
crt.Screen.Send "domain AAAA"&chr(13)
crt.Screen.Send "domain default enable AAAA"&chr(13)
'登录
crt.Screen.Send "local-user AAAA"&chr(13)
crt.Screen.Send "password simple AAAA"&chr(13)
crt.Screen.Send "level 3"&chr(13)
crt.Screen.Send "service-type ssh telnet terminal level 3"&chr(13)
crt.Screen.Send "service-type ssh telnet terminal "&chr(13)
crt.Screen.Send "ssh server enable"&chr(13)
crt.Screen.Send "ssh server enable"&chr(13)
crt.Screen.Send "ssh user AAAA service-type stelnet "&chr(13)
crt.Screen.Send "user-interface aux 0"&chr(13)
crt.Screen.Send " "& chr(13)&"set authentication password simple "& InputBox("","输入console密码","AAAA") & chr(13)
crt.Screen.Send "user-interface vty 0 4"&chr(13)
crt.Screen.Send "acl AAAA inbound"&chr(13)
crt.Screen.Send "protocol inbound all"&chr(13)
crt.Screen.Send "user privilege level 3 "&chr(13)
crt.Screen.Send "authentication-mode scheme "&chr(13)
crt.Screen.Send "quit"&chr(13)
crt.Screen.Send "rsa local-key-pair create"&chr(13)&chr(13)
crt.Sleep 3000
crt.Screen.Send "ssh authentication-type default all"&chr(13)
'MsgBox("下面进行access端口配置")
crt.Screen.Send " "& chr(13)&"interface range "& InputBox("输入要批量配置的端口Ethernet& GigabitEth","access端口","Ethernet 1/0/1 to Ethernet 1/0/8") & chr(13)
crt.Screen.Send " "& chr(13)&"port access vlan "& InputBox("access vlan","access 端口vlan","100") & chr(13)
crt.Screen.Send "quit"&chr(13)
'MsgBox("下面进行trunk端口配置")
crt.Screen.Send " "& chr(13)&"interface range "& InputBox("输入要批量配置的端口Ethernet& GigabitEth interface range","trunk端口","GigabitEth 1/0/9 to GigabitEth 1/0/9") & chr(13)
crt.Screen.Send " "& chr(13)&"port link-type trunk"& chr(13) &InputBox("trunk端口","端口vlan","port trunk permit vlan all") & chr(13)
crt.Screen.Send "dhcp snooping trust"&chr(13)
crt.Screen.Send "dhcp-snooping trust" & chr(13)
crt.Screen.WaitForString "]"
crt.Screen.Send "quit"&chr(13)
End If
End If
End If
Next
End Sub