sdfouhdso888 发表于 2017-7-8 17:09:19

python2计算cisco无线AP需要dhcp的option43

#/usr/bin/python2.7
# -*- coding=utf-8 -*-
import socket
from binascii import hexlify
import sys


def wlc_option43_hex():
wlc_number = raw_input('Enter the wlc number:')
if wlc_number == '1':
put_number = raw_input('Enter the wlc ip:')
for ip_addr in :
wlc_ip_addr = socket.inet_aton(ip_addr)
unpacked_ip_addr = socket.inet_ntoa(wlc_ip_addr)
hex_prefix = 'f104'
result=hex_prefix+hexlify(wlc_ip_addr)
print "IP Address: %s => option43 hex %s"\
%(unpacked_ip_addr,result+'.'+result+'.'+result)

else:
put_number1 = raw_input('Enter the wlc ip:')
for ip_addr1 in :
wlc_ip_addr1= socket.inet_aton(ip_addr1)
unpacked_ip_addr1 = socket.inet_ntoa(wlc_ip_addr1)
hex_prefix = 'f108'
result1=hexlify(wlc_ip_addr1)
put_number2 = raw_input('Enter the wlc ip:')
for ip_addr2 in :
wlc_ip_addr2=socket.inet_aton(ip_addr2)
unpacked_ip_addr2 = socket.inet_ntoa(wlc_ip_addr2)
result2=hexlify(wlc_ip_addr2)

result = hex_prefix+result1+result2
print "IP Address: %s %s => option43 hex %s"\
%(unpacked_ip_addr1,unpacked_ip_addr2,result+'.'+result+'.'+result+'.'+result+'.'+result)



if __name__ == '__main__':
wlc_option43_hex()


#一台cisco无线控制器

#Enter the wlc number:1

#Enter the wlc ip:10.10.9.245

#IP Address: 10.10.9.245 => option43 hex f104.0a0a.09f5

#两台cisco无线控制器

#Enter the wlc number:2

#Enter the wlc ip:10.10.1.123

#Enter the wlc ip:10.10.1.124

#IP Address: 10.10.1.123 10.10.1.124 => option43 hex f108.0a0a.017b.0a0a.017c
页: [1]
查看完整版本: python2计算cisco无线AP需要dhcp的option43