Exemplo n.º 1
0
def teGlobal():
	if mpls == True:	
		 if te == True:
			 print "mpls traffic-eng "
			 for i in range(lengh):
				if hostNum == intf[i]:
					continue	 
		
				mini, maxi = minMax(hostNum,intf[i])
		
				print " interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
				print " !"
			 print " "
			 
			 print "rsvp"
			 for i in range(lengh):
				if hostNum == intf[i]:
					continue	 
		
				mini, maxi = minMax(hostNum,intf[i])
		
				print " interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
			 	print "  bandwidth " + rsvp
				print " !"
			 print " "
Exemplo n.º 2
0
def mplsGlobal():
	if mpls == True:
		print "mpls ldp "
		print " router-id " + hostNum + "." + hostNum + "." + hostNum + "." + hostNum
		for i in range(lengh):
			if hostNum == intf[i]:
				continue	 
		
			mini, maxi = minMax(hostNum,intf[i])
		
			print "  interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
			print "  !"
		print " "
		print "mpls label range 10" + hostNum + "000 10" + hostNum + "999"
		print " "
Exemplo n.º 3
0
	else:
		print "int l10"
		print " vrf forwarding " + vrf_name
		print " ip add " + lo_vrf + " 255.255.255.255"
		if ipv6 == True:
			print " ipv6 add 2001::" + lo_vrf.replace(".", ":") + "/128"
		if multicast == True:
			pimInt()
			print " ip igmp join " + igmp
		print 
	
	for i in range(lengh):
		if hostNum == intf[i]:
			continue	 
		
		mini, maxi = minMax(hostNum,intf[i])
		
		print "interface " + interfaceName + "0/" + int_no + "." + mini + maxi
		print " enc dot " + mini + maxi
		if igp == None:
			if args.vrf != None:
				print " vrf forwarding " + vrf_name
		print " ip add 10." + mini + "." + maxi + "." + hostNum + " 255.255.255.0"
		if ipv6 == True:
			print " ipv6 add 2001:10:" + mini + ":" + maxi + "::" + hostNum + "/64"
			print " ipv6 add fe80::10:" + mini + ":" + maxi + ":" + hostNum + " link-local"
		if igp == "ospf":
			print " ip ospf 1 a " + area 
			print " ip ospf network point-to-point"
			if ipv6 == True:
				print " ipv6 ospf 1 a " + area 
Exemplo n.º 4
0
def multicastGlobal(vrf = ''):

	if vrf == '':
		if multicast == True:
			print "multicast-routing"
			print " address-family ipv4"
			for i in range(lengh):
				if hostNum == intf[i]:
					continue	 
			
				mini, maxi = minMax(hostNum,intf[i])
			
				print " interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
				print " !"
			print ""
			print "router igmp"
			print "  interface lo0"
			print "   join-group " + igmp
			print ""
			print "router pim"
			print " address-family ipv4"
			for i in range(lengh):
				if hostNum == intf[i]:
					continue	 
			
				mini, maxi = minMax(hostNum,intf[i])
			
				print " interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
				print " !"

			print " rp-address " + rp
			print ""
	else:
		if multicast == True:
			print "multicast-routing"
			print " vrf " + vrf
			print "  address-family ipv4"
			if mdt != '':
				print "  mdt default " + mdt
				print "  mdt source l0"
			for i in range(lengh):
				if hostNum == intf[i]:
					continue	 
			
				mini, maxi = minMax(hostNum,intf[i])
			
				print "  interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
				print "  !"
			print ""
			print "router igmp"
			print "  vrf " + vrf
			print "  interface lo10"
			print "   join-group " + igmp
			print ""
			print "router pim"
			print " vrf " + vrf
			print "  address-family ipv4"
			for i in range(lengh):
				if hostNum == intf[i]:
					continue	 
			
				mini, maxi = minMax(hostNum,intf[i])
			
				print "  interface " + interfaceName + "0/0/0/" + int_no + "." + mini + maxi
				print "  !"

			print "  rp-address " + rp
			print ""
Exemplo n.º 5
0
def ebgpON(router, neigh_list, asn, af, whois, vrf=''):

    rrc = []
    if bgp == "YES":
        rid = ip(router)
        print
        print "route-policy pass"
        print " pass"
        print "end-policy"
        print
        print "router bgp " + asn
        print " bgp router-id " + rid
        print

        local = router
        neigh = neigh_list.split(',')[0]

        mini, maxi = minMax(local, neigh)

        if vrf == '':
            if af == 4 or af == 46:
                print " address-family ipv4 unicast"
                print "  network " + rid + "/32"
                print " !"
                print " neighbor 10." + mini + "." + maxi + "." + neigh
                print "  remote-as " + neigh_list.split(",")[1]
                print "  address-family ipv4 unicast"
                print "   send-community-ebgp"
                print "   route-policy pass in"
                print "   route-policy pass out"
                print "  "

            if af == 6 or af == 46:
                print "router bgp " + asn
                print " address-family ipv6 unicast"
                print "  network 2001::" + local + ":" + local + ":" + local + ":" + local + "/128"
                print " !"
                print " neighbor 2001:10:" + mini + ":" + maxi + "::" + neigh
                print "  remote-as " + neigh_list.split(",")[1]
                print "  address-family ipv6 unicast"
                print "   send-community-ebgp"
                print "   route-policy pass in"
                print "   route-policy pass out"
                print "  "

        else:
            if af == 4 or af == 46:
                print " !"
                print " vrf " + vrf
                print "  rd auto"
                print "  address-family ipv4 unicast "
                print "   redistribute connected route-policy VRF-C-4"
                print "   redistribute static"
                print "  !"
                print "  neighbor 10." + mini + "." + maxi + "." + neigh
                print "   remote-as " + neigh_list.split(",")[1]
                print "   address-family ipv4 unicast"
                print "    send-community-ebgp"
                print "    route-policy pass in"
                print "    route-policy pass out"
                print "    as-override"
                print
                print "route-policy VRF-C-4"
                print " if destination in (0.0.0.0/0 ge 32) then"
                print "  pass"
                print " endif"
                print "end-policy"
                print

            if af == 6 or af == 46:
                print "router bgp " + asn
                print " !"
                print " vrf " + vrf
                print "  rd auto"
                print "  address-family ipv6 unicast "
                print "   redistribute connected route-policy VRF-C-6"
                print "   redistribute static"
                print "  !"
                print "  neighbor 2001:10:" + mini + ":" + maxi + "::" + neigh
                print "   remote-as " + neigh_list.split(",")[1]
                print "   address-family ipv6 unicast"
                print "    send-community-ebgp"
                print "    route-policy pass in"
                print "    route-policy pass out"
                print "    as-override"
                print
                print "route-policy VRF-C-6"
                print " if destination in (::/0 ge 128) then"
                print "  pass"
                print " endif"
                print "end-policy"
                print

        if whois == True:
            if af == 4 or af == 46:
                print " !"
                print "router bgp " + asn
                print " address-family ipv4 unicast"
                print "  redistribute static route-policy TAG"

                print
                print "route-policy TAG"
                print " if tag is 100 then"
                print "  pass"
                print " endif"
                print "end-policy"
                print

                query = "-T route -i origin AS" + asn
                result = queryWhois(query, "whois.ripe.net").split("\n")

                print "router static "
                print " address-family ipv4 unicast"
                for line in result:
                    if re.search("route:", line):
                        print "  " + sn(
                            line.strip("route:          ")) + " null0 tag 100"

            if af == 6 or af == 46:
                print " !"
                print "router bgp " + asn
                print " address-family ipv6 unicast"
                print "  redistribute static route-policy TAG"

                print
                print "route-policy TAG"
                print " if tag is 100 then"
                print "  pass"
                print " endif"
                print "end-policy"
                print

                query = "-T route6 -i origin AS" + asn
                result = queryWhois(query, "whois.ripe.net").split("\n")

                print "router static "
                print " address-family ipv6 unicast"
                for line in result:
                    if re.search("route6:", line):
                        print "  " + line.strip(
                            "route6:          ") + " null0 tag 100"
Exemplo n.º 6
0
def ebgpON(router, neigh_list, asn, af, whois, vrf = ''):

    rrc = []
    if bgp == "YES":
        rid = ip(router)
        print ""
        print "ip bgp new-format"
        print ""
        print "router bgp " + asn
        print " bgp router-id " + rid
        print " no bgp default ipv4"

        local = router
        neigh = neigh_list.split(',')[0]

        mini, maxi = minMax(local,neigh)

        if vrf == '':
			if af == 4 or af == 46:
				print " neigh 10." + mini + "." + maxi + "." + neigh + " remote-as " + neigh_list.split(",")[1]
				print " !"
				print " add ipv4 unicast"
				print "  network " + rid + " mask 255.255.255.255"
				print "  neigh 10." + mini + "." + maxi + "." + neigh + " activate"
				print "  neigh 10." + mini + "." + maxi + "." + neigh + " send-comm both"
				print "  "

			if af == 6 or af == 46:
				print "router bgp " + asn
				print " neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " remote-as " + neigh_list.split(",")[1]
				print " !"
				print " add ipv6 unicast"
				print "  network 2001::" + local + ":" + local + ":" + local + ":" + local + "/128"
				print "  neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " activate"
				print "  neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " send-comm both"
				print "  "
        else:
            if af == 4 or af == 46:
                print " !"
                print " add ipv4 vrf " + vrf
                print "  redistribute connected route-map VRF-C-4"
                print "  redistribute static"
                print "  neigh 10." + mini + "." + maxi + "." + neigh + " remote-as " + neigh_list.split(",")[1]
                print "  neigh 10." + mini + "." + maxi + "." + neigh + " activate"
                print "  neigh 10." + mini + "." + maxi + "." + neigh + " send-comm both"
                print "  neigh 10." + mini + "." + maxi + "." + neigh + " as-override"
                print
                print "ip prefix-list VRF-C-4-PFX permit 0.0.0.0/0 ge 32"
                print
                print " route-map VRF-C-4 permit 10"
                print "  match ip address prefix-list VRF-S-4-PFX"

            if af == 6 or af == 46:
                print "router bgp " + asn
                print " !"
                print " add ipv6 vrf " + vrf
                print "  redistribute connected route-map VRF-C-6"
                print "  redistribute static"
                print "  neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " remote-as " + neigh_list.split(",")[1]
                print "  neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " activate"
                print "  neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " send-comm both"
                print "  neigh 2001:10:" + mini + ":" + maxi + "::" + neigh + " as-override"
                print 
                print "ipv6 prefix-list VRF-C-6-PFX permit ::/0 ge 128"
                print
                print " route-map VRF-C-6 permit 10"
                print "  match ipv6 address prefix-list VRF-C-6-PFX"

        if whois == True:
            if af == 4 or af == 46:
                print " !"
                print " add ipv4 unicast"
                print "  redistribute static route-map TAG"

                print " "
                print "route-map TAG permit 10"
                print " match tag 100"
                print " "

                query = "-T route -i origin AS" + asn
                result = queryWhois(query, "whois.ripe.net").split("\n")

                for line in result:
                    if re.search("route:", line):
                        print "ip route " + sn(line.strip("route:          ")) + " null0 tag 100"

            if af == 6 or af == 46:
                print " !"
                print " add ipv6 unicast"
                print "  redistribute static route-map TAG"

                print " "
                print "route-map TAG permit 10"
                print " match tag 100"
                print " "

                query = "-T route6 -i origin AS" + asn
                result = queryWhois(query, "whois.ripe.net").split("\n")

                for line in result:
                    if re.search("route6:", line):
                        print "ipv6 route " + line.strip("route6:          ") + " null0 tag 100"