2023年12月7日发(作者:瞿姝)
单个华为交换机自动透传vlan
工具:secureCRT 语言:vbs 整理:鲍继川 邮箱:bc5367@gmailaaa
1. 文件
Xxxx_9306
2012
G1/0/0 G1/0/2 g1/0/3
第一行为交换机名称
第二行为vlan
第三行为要透传的端口
2 交换机信息文件
交换机.txt
1.1.1.1 用户名 密码 super3密码
2.2.2.2 用户名 密码 super3密码
———————————————————————————————————————
3 通过读取 文件的第一行,找到交换机信息文件里德信息后登陆进去,取得的第二行为vlan信息。取得第三行作为交换机端口,准备透传。
完整代码如下:
# $language = "VBScript"
# $interface = "1.0"
Sub Main
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim objTab,flag
on error goto 0
flag=0
Set objTab = iptTab
Set fso1 = CreateObject("stemObject")
Set fso4 = CreateObject("stemObject")
onous = True
str1="e:/easy/"
if not ists(str1) then
1 / 5 eBox "交换机透传文件不存在" & vbcrlf & _
vbcrlf & _
str1 & vbcrlf & vbcrlf & _
"请重新运行脚本!"
exit Sub
end if
Set file1 = xtFile(str1,1, False)
line1=""
line1 = Trim(ne)
if line1="" then
eBox "交换机为空!"
exit sub
end if
dim line2,line3,line4
str4="E:easy交换机"
Set file4= xtFile(str4,1, False)
do
line4=Trim(ne)
if(line4="") then
exit sub
end if
params=Split(line4)
if(line1=params(1)) then
flag=1
'msgbox(flag)
exit do
end if
loop until fStream=True
if flag=0 then
msgbox("没找到交换机")
exit sub
end if
line2 = Trim(ne)
line3 = Trim(ne)
l=Split(line3)
if(line2="")then
msgbox("vlan为空")
2 / 5 exit Sub
end if
if(line3="")then
msgbox("端口为空")
exit Sub
end if
eName = "e:easylog" & Date & "" & params(0) & ".txt"
(true)
'Telnet到这个设备上
t "/TELNET " & params(0)
onous = True
rString "Username:"
params(1) & chr(13)
rString "Password:"
params(2) & chr(13)
rString ">"
"super 3" & chr(13)
rString " Password:"
params(3) & chr(13)
rString ">"
"sys" & chr(13)
rString "]"
skey=InStr(params(1),5)
select case skey
case 0
"vlan ba " & line2 & chr(13)
for i=0 to UBound(l)
rString "]"
"int "& l(i)&chr(13)
rString "]"
"port tr al vl "&line2&chr(13)
rString "]"
"quit"&chr(13)
3 / 5 next
case else
"vlan " & line2 & chr(13)
for i=0 to UBound(l)
rString "]"
"int "& l(i)&chr(13)
rString "]"
"port tr per vl "&line2&chr(13)
rString "]"
"quit"&chr(13)
next
end select
rString "]"
"quit" & chr(13)
rString ">"
"sa" & chr(13)
'rString "Are you sure to continue?[Y/N]"
'rString "@",1
"y" & chr(13)
rString "#", 2
nect
()
Call (False)
onous = False
end Sub
4 / 5 实际运行效果如下:
***********************************************************
* All rights reserved (2003-2009) *
* Without the owner's prior written consent, *
* no decompiling or reverse-engineering shall be allowed. *
* Notice: *
* This is a private communication system. *
* Unauthorized access or use may lead to prosecution. *
***********************************************************
Login authentication
Username:_9306
Password:
Info: The max number of VTY users is 10, and the number
of current VTY users on line is 1.
<_S9306>super 3
Password:
Warning: Now user privilege is level 3, and only those commands whose level is equal to or less
than this level can be used.
Privilege note: 0-VISIT, 1-MONITOR, 2-SYSTEM, 3-MANAGE
<_S9306>sys
Enter system view, return user view with Ctrl+Z.
[_S9306]vlan ba 2016
[_S9306]int g1/0/6
[_S9306-GigabitEthernet1/0/6]port tr al vl 2016
[_S9306-GigabitEthernet1/0/6]quit
[_S9306]quit
<_S9306>sa
The current configuration will be written to the device. Continue? [Y/N]:y
Now saving the current configuration to
Info: Succeeded in saving the current configuration to the master board device..
[文档可能无法思考全面,请浏览后下载,另外祝您生活愉快,工作顺利,万事如意!]
5 / 5
2023年12月7日发(作者:瞿姝)
单个华为交换机自动透传vlan
工具:secureCRT 语言:vbs 整理:鲍继川 邮箱:bc5367@gmailaaa
1. 文件
Xxxx_9306
2012
G1/0/0 G1/0/2 g1/0/3
第一行为交换机名称
第二行为vlan
第三行为要透传的端口
2 交换机信息文件
交换机.txt
1.1.1.1 用户名 密码 super3密码
2.2.2.2 用户名 密码 super3密码
———————————————————————————————————————
3 通过读取 文件的第一行,找到交换机信息文件里德信息后登陆进去,取得的第二行为vlan信息。取得第三行作为交换机端口,准备透传。
完整代码如下:
# $language = "VBScript"
# $interface = "1.0"
Sub Main
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim objTab,flag
on error goto 0
flag=0
Set objTab = iptTab
Set fso1 = CreateObject("stemObject")
Set fso4 = CreateObject("stemObject")
onous = True
str1="e:/easy/"
if not ists(str1) then
1 / 5 eBox "交换机透传文件不存在" & vbcrlf & _
vbcrlf & _
str1 & vbcrlf & vbcrlf & _
"请重新运行脚本!"
exit Sub
end if
Set file1 = xtFile(str1,1, False)
line1=""
line1 = Trim(ne)
if line1="" then
eBox "交换机为空!"
exit sub
end if
dim line2,line3,line4
str4="E:easy交换机"
Set file4= xtFile(str4,1, False)
do
line4=Trim(ne)
if(line4="") then
exit sub
end if
params=Split(line4)
if(line1=params(1)) then
flag=1
'msgbox(flag)
exit do
end if
loop until fStream=True
if flag=0 then
msgbox("没找到交换机")
exit sub
end if
line2 = Trim(ne)
line3 = Trim(ne)
l=Split(line3)
if(line2="")then
msgbox("vlan为空")
2 / 5 exit Sub
end if
if(line3="")then
msgbox("端口为空")
exit Sub
end if
eName = "e:easylog" & Date & "" & params(0) & ".txt"
(true)
'Telnet到这个设备上
t "/TELNET " & params(0)
onous = True
rString "Username:"
params(1) & chr(13)
rString "Password:"
params(2) & chr(13)
rString ">"
"super 3" & chr(13)
rString " Password:"
params(3) & chr(13)
rString ">"
"sys" & chr(13)
rString "]"
skey=InStr(params(1),5)
select case skey
case 0
"vlan ba " & line2 & chr(13)
for i=0 to UBound(l)
rString "]"
"int "& l(i)&chr(13)
rString "]"
"port tr al vl "&line2&chr(13)
rString "]"
"quit"&chr(13)
3 / 5 next
case else
"vlan " & line2 & chr(13)
for i=0 to UBound(l)
rString "]"
"int "& l(i)&chr(13)
rString "]"
"port tr per vl "&line2&chr(13)
rString "]"
"quit"&chr(13)
next
end select
rString "]"
"quit" & chr(13)
rString ">"
"sa" & chr(13)
'rString "Are you sure to continue?[Y/N]"
'rString "@",1
"y" & chr(13)
rString "#", 2
nect
()
Call (False)
onous = False
end Sub
4 / 5 实际运行效果如下:
***********************************************************
* All rights reserved (2003-2009) *
* Without the owner's prior written consent, *
* no decompiling or reverse-engineering shall be allowed. *
* Notice: *
* This is a private communication system. *
* Unauthorized access or use may lead to prosecution. *
***********************************************************
Login authentication
Username:_9306
Password:
Info: The max number of VTY users is 10, and the number
of current VTY users on line is 1.
<_S9306>super 3
Password:
Warning: Now user privilege is level 3, and only those commands whose level is equal to or less
than this level can be used.
Privilege note: 0-VISIT, 1-MONITOR, 2-SYSTEM, 3-MANAGE
<_S9306>sys
Enter system view, return user view with Ctrl+Z.
[_S9306]vlan ba 2016
[_S9306]int g1/0/6
[_S9306-GigabitEthernet1/0/6]port tr al vl 2016
[_S9306-GigabitEthernet1/0/6]quit
[_S9306]quit
<_S9306>sa
The current configuration will be written to the device. Continue? [Y/N]:y
Now saving the current configuration to
Info: Succeeded in saving the current configuration to the master board device..
[文档可能无法思考全面,请浏览后下载,另外祝您生活愉快,工作顺利,万事如意!]
5 / 5