Advertisement
teknoraver

bridge vlan filtering vs netdev

Jan 28th, 2020
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # cleanup
  4. for i in br-filt br-dev veth-dev veth-filt; do
  5.         [ -d /sys/class/net/$i ] && ip link del dev $i
  6. done
  7. ip -all netns del
  8.  
  9. # create bridges
  10. ip link add br-filt type bridge
  11. ip link add br-dev type bridge
  12. ip link set br-filt up
  13. ip link set br-dev up
  14.  
  15. # create netns and disable IPv6 globally
  16. ip netns add filt
  17. ip netns add dev
  18. sysctl -w net.ipv6.conf.all.disable_ipv6=1
  19. ip -all netns exec sysctl -w net.ipv6.conf.all.disable_ipv6=1
  20.  
  21. # create veth pairs
  22. ip link add veth-dev type veth peer name veth0 netns dev
  23. ip link add veth-filt type veth peer name veth0 netns filt
  24. ip link set veth-filt up
  25. ip link set veth-dev up
  26. ip -n filt link set lo up
  27. ip -n filt link set veth0 up promisc on
  28. ip -n dev link set lo up
  29. ip -n dev link set veth0 up promisc on
  30.  
  31. # add tc drop rule
  32. tc -n dev qdisc replace dev veth0 clsact
  33. tc -n dev filter add dev veth0 ingress matchall action gact drop
  34. tc -n filt qdisc replace dev veth0 clsact
  35. tc -n filt qdisc replace dev veth0 clsact
  36.  
  37. # create vlan dev in bridge with netdev
  38. ip link add veth-dev.1 link veth-dev type vlan id 1
  39. ip link set veth-dev.1 master br-dev
  40. ip link set veth-dev.1 up
  41.  
  42. # add plain veth in bridge with vlan filtering
  43. ip link set veth-filt master br-filt
  44.  
  45. # set vlan filtering
  46. ip link set dev br-filt up type bridge vlan_filtering 1
  47. bridge vlan del vid 1 dev veth-filt
  48. bridge vlan add vid 1 dev veth-filt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement