Skip to content

Instantly share code, notes, and snippets.

@coconut49
Created August 16, 2016 15:59
Show Gist options
  • Save coconut49/4b5d3fdf209ad70556b39429af889590 to your computer and use it in GitHub Desktop.
Save coconut49/4b5d3fdf209ad70556b39429af889590 to your computer and use it in GitHub Desktop.
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