-
-
Save scalp42/9653236 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
| perl -v > /dev/null || exit 1 | |
| m() | |
| { | |
| curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$1 | |
| } | |
| for mac in `m` | |
| do | |
| dev=`m $mac/device-number` | |
| subnet=`m $mac/subnet-ipv4-cidr-block` | |
| gw=`echo $subnet | perl -pe 's#/.+##; @ip=split(/\./); $ip[3]++ ; $_=join(".",@ip)'` | |
| ip route flush table 100$dev | |
| ip route add table 100$dev to $subnet dev eth$dev | |
| ip route add table 100$dev to default via $gw dev eth$dev | |
| ip rule add from $subnet table 100$dev priority 100$dev | |
| done | |
| ip route flush cache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment