Skip to content

Instantly share code, notes, and snippets.

@RPDiep
Created August 13, 2014 07:42
Show Gist options
  • Save RPDiep/7b01ba851df85525acd9 to your computer and use it in GitHub Desktop.
Save RPDiep/7b01ba851df85525acd9 to your computer and use it in GitHub Desktop.
A script to label the secondary ipv6 addresses differently, thus making the first ipv6 the default for outgoing connections
#!/bin/bash
ETH=$(ip -6 r | awk '/^default/ {print $5}')
for IP in $(awk -F '=' '/IPV6ADDR_SECONDARIES/ {gsub("\"",""); gsub("/[0-9]*","/128"); print $2}' /etc/sysconfig/network-scripts/ifcfg-${ETH})
do
ip addrlabel add prefix ${IP} label 1001
done
@RPDiep
Copy link
Author

RPDiep commented Aug 13, 2014

In CentOS6, you can run this script after network startup by adding it in /sbin/ifup-local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment