Skip to content

Instantly share code, notes, and snippets.

@fstern
Last active January 25, 2018 11:40
Show Gist options
  • Save fstern/2595d0b49a19c62d52bfcb23ec411af2 to your computer and use it in GitHub Desktop.
Save fstern/2595d0b49a19c62d52bfcb23ec411af2 to your computer and use it in GitHub Desktop.
Mapping VLAN interfaces to VRFs
egrep -i '(^interface vlan)|(ip vrf forwarding)' showstartup-config-600.txt |\
perl -e 'while (<>) { print $1,"\n" if m/^interface\sVlan(\d+)/; print $1,"\n" if m/\sip vrf forwarding (\w+)/}' |\
tail -n +6 | paste - - -d, |\
perl -e 'while (<>) { chomp; ($vl,$vrf) = split(/,/,$_); push @{$map->{$vrf}},$vl; } ; foreach (keys(%{$map})) { print $_, " ", join(",",@{$map->{$_}}),"\n" }; '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment