-
-
Save flashvoid/7765f278ec3c6b68200ffbb308edc75a to your computer and use it in GitHub Desktop.
overlay on gce with vxlan unicast flood
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
{ | |
"c1": { | |
"hostname": "netlab-1-0xwl", | |
"interfaces": { | |
"vx1" : { | |
"oip": "192.168.1.2/24", | |
"vid": 1, | |
"remotes": [ | |
"10.240.0.8" | |
] | |
} | |
}, | |
"uip": "10.240.0.5" | |
}, | |
"r1": { | |
"hostname": "netlab-1-7thz", | |
"interfaces": { | |
"vx1" : { | |
"oip": "192.168.1.1/24", | |
"vid": 1, | |
"remotes": [ | |
"10.240.0.5" | |
] | |
}, | |
"vx4" : { | |
"oip": "192.168.4.1/24", | |
"vid": 4, | |
"remotes": [ | |
"10.240.0.6" | |
] | |
}, | |
"vx3" : { | |
"oip": "192.168.3.1/24", | |
"vid": 3, | |
"remotes": [ | |
"10.240.0.3" | |
] | |
} | |
}, | |
"uip": "10.240.0.8" | |
}, | |
"bgp": { | |
"hostname": "netlab-1-b2d5", | |
"interfaces": { | |
"vx3" : { | |
"oip": "192.168.3.3/24", | |
"vid": 3, | |
"remotes": [ | |
"10.240.0.8", | |
"10.240.0.6" | |
] | |
} | |
}, | |
"uip": "10.240.0.3" | |
}, | |
"r2": { | |
"hostname": "netlab-1-r30m", | |
"interfaces": { | |
"vx4" : { | |
"oip": "192.168.4.2/24", | |
"vid": 4, | |
"remotes": [ | |
"10.240.0.8" | |
] | |
}, | |
"vx2" : { | |
"oip": "192.168.2.1/24", | |
"vid": 2, | |
"remotes": [ | |
"10.240.0.7" | |
] | |
}, | |
"vx3" : { | |
"oip": "192.168.3.2/24", | |
"vid": 3, | |
"remotes": [ | |
"10.240.0.3" | |
] | |
} | |
}, | |
"uip": "10.240.0.6" | |
}, | |
"c2": { | |
"hostname": "netlab-1-t7pr", | |
"interfaces": { | |
"vx2" : { | |
"oip": "192.168.2.3/24", | |
"vid": 2, | |
"remotes": [ | |
"10.240.0.6" | |
] | |
} | |
}, | |
"uip": "10.240.0.7" | |
} | |
} |
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
r2 sudo sysctl net.ipv4.conf.all.forwarding=1 | |
r1 sudo sysctl net.ipv4.conf.all.forwarding=1 | |
c1 sudo sysctl net.ipv4.conf.all.forwarding=1 | |
c2 sudo sysctl net.ipv4.conf.all.forwarding=1 | |
c1 sudo ip ro add 192.168.2.0/24 via 192.168.1.1 | |
c1 sudo ip ro add 192.168.3.0/24 via 192.168.1.1 | |
c2 sudo ip ro add 192.168.1.0/24 via 192.168.2.1 | |
c2 sudo ip ro add 192.168.3.0/24 via 192.168.2.1 | |
bgp sudo ip ro add 192.168.1.0/24 via 192.168.3.1 | |
bgp sudo ip ro add 192.168.2.0/24 via 192.168.3.2 | |
r1 sudo ip ro add 192.168.2.0/24 via 192.168.4.2 | |
r2 sudo ip ro add 192.168.1.0/24 via 192.168.4.1 |
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/bash -ex | |
set_if () { | |
hostname=$(jq -r '.hostname' <<< $1) | |
uip=$(jq '.uip' <<< $1) | |
interfaces=$(jq -r '.interfaces | keys | .[]' <<< $1) | |
for if in $( echo $interfaces); do | |
oip=$(jq -r ".interfaces.${if}.oip" <<< $1) | |
vid=$(jq -r ".interfaces.${if}.vid" <<< $1) | |
remotes=$(jq -r ".interfaces.${if}.remotes | .[]" <<< $1) | |
gcloud compute ssh $hostname -- sudo ip link add $if type vxlan id $vid dstport 4789 local $uip | |
gcloud compute ssh $hostname -- sudo ip link set $if up | |
gcloud compute ssh $hostname -- sudo ip a add $oip dev $if | |
for remote in $remotes; do | |
gcloud compute ssh $hostname -- sudo bridge fdb append 00:00:00:00:00:00 dev $if dst $remote | |
done | |
done | |
} | |
do_host () { | |
host=$(jq ".${1}" < data) | |
set_if "$host" | |
} | |
do_host "c1" | |
do_host "r1" | |
do_host "bgp" | |
do_host "r2" | |
do_host "c2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment