Skip to content

Instantly share code, notes, and snippets.

@gizmoguy
Last active July 22, 2019 09:43
Show Gist options
  • Save gizmoguy/ec83fd877814a177823313c91a49b88b to your computer and use it in GitHub Desktop.
Save gizmoguy/ec83fd877814a177823313c91a49b88b to your computer and use it in GitHub Desktop.
Dynamically assign hosts to VLANs with FAUCET SDN Controller
acls:
assign-host-to-experiment-vlan:
# Send packets from host1 to experiment1 vlan
- rule:
eth_src: 2e:f6:43:15:c1:7d # host1 mac
actions:
output:
swap_vid: 101 # experiment1 vlan
allow: 1 # allow
- rule:
eth_src: ba:6f:f6:1f:be:37 # host2 mac
actions:
output:
swap_vid: 102 # experiment2 vlan
allow: 1 # allow
assign-to-host-vlan:
- rule:
vlan_vid: "0x1000/0x1000" # match all vlans
actions:
force_port_vlan: 1
output:
swap_vid: 100 # host vlan
allow: 1 # allow
default_allow:
# Default allow any other packets to be processed normally
- rule:
actions:
allow: 1 # allow
default_drop:
# Default drop any other packets
- rule:
actions:
allow: 0 # drop
include:
- acls.yaml
vlans:
host:
vid: 100
description: "Default VLAN when not assigned to an experiment"
acls_in: [assign-host-to-experiment-vlan, default_allow]
experiment1:
vid: 101
description: "Experiment #1"
experiment2:
vid: 102
description: "Experiment #2"
experiment3:
vid: 103
description: "Experiment #3"
dps:
sw1:
dp_id: 0x1
hardware: "CiscoC9K"
interfaces:
1:
name: "host1"
description: "host1 container"
native_vlan: host
2:
name: "host2"
description: "host2 container"
native_vlan: host
3:
name: "host3"
description: "host3 container"
native_vlan: host
4:
name: "trunk"
description: "VLAN trunk to sw2"
tagged_vlans: [host, experiment1, experiment2, experiment3]
acls_in: [assign-to-host-vlan, default_allow]
sw2:
dp_id: 0x2
hardware: "Allied-Telesis"
interfaces:
1:
name: "server1"
description: "server1 for experiment #1"
native_vlan: experiment1
2:
name: "server2"
description: "server2 for experiment #2"
native_vlan: experiment2
3:
name: "server3"
description: "server3 for experiment #3"
native_vlan: experiment3
4:
name: "server4"
description: "server4 for experiments #2 and #3"
tagged_vlans: [experiment2, experiment3]
5:
name: "trunk"
description: "VLAN trunk to sw1"
tagged_vlans: [host, experiment1, experiment2, experiment3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment