Commit bdc2d63f authored by David Johnson's avatar David Johnson

Only enable routing/seg6 on routers.

parent f6fd727d
Pipeline #3061 passed with stages
in 15 seconds
...@@ -49,36 +49,38 @@ if not node: ...@@ -49,36 +49,38 @@ if not node:
print "Setting addresses for %s ..." % (hostname,) print "Setting addresses for %s ..." % (hostname,)
(dev,mac) = (None,None)
addrs = []
for i in node.findall("g:interface",namespaces=nsmap): for i in node.findall("g:interface",namespaces=nsmap):
mac = i.get("mac_address") mac = i.get("mac_address")
dev = None
if mac: if mac:
dev = findif(mac=mac) dev = findif(mac=mac)
addrs = []
for a in i.findall("c:ip",namespaces=nsmap): for a in i.findall("c:ip",namespaces=nsmap):
if a.get("type") != "ipv6": if a.get("type") != "ipv6":
continue continue
(addr,prefixlen) = (a.get("address"),a.get("prefixlen")) (addr,prefixlen) = (a.get("address"),a.get("prefixlen"))
addrs.append("%s/%s" % (addr,prefixlen)) addrs.append("%s/%s" % (addr,prefixlen))
if dev and addrs: if dev and len(addrs) > 1:
print "Enabling overall ipv6 forwarding and segment routing..." print "Enabling overall ipv6 forwarding and segment routing..."
os.system("sysctl -w net.ipv6.conf.all.forwarding=1") os.system("sysctl -w net.ipv6.conf.all.forwarding=1")
os.system("sysctl -w net.ipv6.conf.all.seg6_enabled=1") os.system("sysctl -w net.ipv6.conf.all.seg6_enabled=1")
print "Enabling segment routing for %s ..." % (dev,) print "Enabling segment routing for %s ..." % (dev,)
os.system("sysctl -w net.ipv6.conf.%s.seg6_enabled=1" % (dev,)) os.system("sysctl -w net.ipv6.conf.%s.seg6_enabled=1" % (dev,))
print "Enabling ipv6 forwarding for %s ..." % (dev,) print "Enabling ipv6 forwarding for %s ..." % (dev,)
os.system("sysctl -w net.ipv6.conf.%s.forwarding=1" % (dev,)) os.system("sysctl -w net.ipv6.conf.%s.forwarding=1" % (dev,))
print "Disabling ipv6 autoconf for %s ..." % (dev,) if dev:
os.system("sysctl -w net.ipv6.conf.%s.autoconf=0" % (dev,)) print "Disabling ipv6 autoconf for %s ..." % (dev,)
print "Flushing existing ipv6 addresses for %s ..." % (dev,) os.system("sysctl -w net.ipv6.conf.%s.autoconf=0" % (dev,))
os.system("ip -6 addr flush dev %s" % (dev,)) print "Flushing existing ipv6 addresses for %s ..." % (dev,)
print "Downing interface %s to allow sysctls to take effect ..." % (dev,) os.system("ip -6 addr flush dev %s" % (dev,))
os.system("ip link set %s down" % (dev,)) print "Downing interface %s to allow sysctls to take effect ..." % (dev,)
for a in addrs: os.system("ip link set %s down" % (dev,))
print "Adding address %s to %s" % (a,dev) if dev and len(addrs):
os.system("ip -6 addr add %s dev %s" % (a,dev)) for a in addrs:
print "Bringing up interface %s ..." % (dev,) print "Adding address %s to %s" % (a,dev)
os.system("ip link set %s up" % (dev,)) os.system("ip -6 addr add %s dev %s" % (a,dev))
print "Bringing up interface %s ..." % (dev,)
os.system("ip link set %s up" % (dev,))
# Collect ipv6 addrs for /etc/hosts # Collect ipv6 addrs for /etc/hosts
hostslines = [] hostslines = []
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment