为了快速生成有规律的VRF,写了一个python脚本,可以快速生成如下的VRF配置。

ip vpn-instance  vpn0
ipv4-family 
route-distinguisher 600:600
vpn-target 600:600 both
quit
quit

#!/usr/bin/python2.7

def main():
f = open('./vrf.txt', 'w') for i in range(0,500):
vrf = "vpn"+str(i)
vlan = 600 + i f.write("ip vpn-instance " + vrf + "\n")
f.write("ipv4-family " + "\n")
f.write("route-distinguisher " + str(vlan) + ":" + str(vlan) + "\n")
f.write("vpn-target " + str(vlan) + ":" + str(vlan) + " both \n")
f.write("quit " + "\n")
f.write("quit" + "\n")
f.write("\r\n") f.close() if __name__ == '__main__':
main()

运行后可以理解生成vrf.txt文件。

04-25 12:57