Created
August 16, 2016 15:59
-
-
Save coconut49/4b5d3fdf209ad70556b39429af889590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import iptools | |
with open("chn.txt") as f,open("chnroute-ipip.txt",mode="w") as o: | |
line = f.readline() | |
while line: | |
ip,netmask = line.split(" ") | |
print("Now Processing IP: "+str(ip)+" Netmask: "+str(netmask)) | |
cidr = iptools.ipv4.netmask2prefix(str(netmask)) | |
o.writelines("prefixcmd "+str(ip)+"/"+str(cidr)+" suffixcmd\n") | |
line = f.readline() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment