Created
September 7, 2018 20:47
-
-
Save Jcpetrucci/ea6fb4ab2c39d45ffbc795958ec277a0 to your computer and use it in GitHub Desktop.
F5 VLAN and Self IP generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read VLAN_ID VLAN_NAME SUBNET MASKLEN; do | |
export MEMBER_A_IP=${SUBNET%.*}.252/${MASKLEN} | |
export MEMBER_B_IP=${SUBNET%.*}.253/${MASKLEN} | |
export VIP=${SUBNET%.*}.254/${MASKLEN} | |
for member in A B; do | |
printf 'For member %s:\n' $member | |
printf 'create net vlan %s interfaces add { internal { tagged } } tag %s\n' $VLAN_NAME $VLAN_ID | |
printf 'create net self me.%s { address %s traffic-group traffic-group-local-only vlan %s }\n' $VLAN_NAME $(eval echo '$MEMBER_'$member'_IP') $VLAN_NAME | |
printf 'create net self float.%s { address %s traffic-group traffic-group-1 vlan %s }\n' $VLAN_NAME $VIP $VLAN_NAME | |
printf '\n\n' | |
done | |
done < "${1:-/proc/self/fd/0}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment