TDCroPower

vlan Skript

Jul 5th, 2024
1,158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.76 KB | None | 0 0
  1. #!/bin/sh
  2. # Set up a VLAN interface on an existing Synology network interface
  3. #
  4. # Copyright (c) 2023 Navigio UG (haftungsbeschränkt)
  5. # This software is provided 'as-is', without any express or implied warranty.
  6. # In no event will the authors be held liable for any damages arising from the use of this software.
  7. #
  8. # Permission is granted to anyone to use this software for any purpose, including
  9. # commercial applications, and to alter it and redistribute it freely.
  10. #
  11. # On Host this file needs to be placed into
  12. # /usr/local/etc/rc.d
  13. # insmod /lib/modules/8021q.ko
  14.  
  15. ##### KONFIGURATION #####
  16. # Insert your changes here...
  17. EthernetInterface="eth0"
  18. BridgeInterface="mvlbr"
  19. VlanID="200"
  20. HostIP="192.168.200.2/24"
  21. BroadcastIP="192.168.200.255"
  22. ContainerAccessIP="192.168.200.254/32"
  23. ContainerNetwork="192.168.200.0/24"
  24. ##### KONFIGURATION #####
  25.  
  26. #### DON'T TOUCH HERE ANYTHING #######
  27. # First delete possibly existing VLAN interfaces
  28. ip link del ${BridgeInterface}.${VlanID}
  29. ip link del ${EthernetInterface}.${VlanID}
  30.  
  31. # Set up networking interface on VLAN ID
  32. # Prerequisite: VLAN has to be set up on router or L3 switch
  33. ip link add link ${EthernetInterface} name ${EthernetInterface}.${VlanID} type vlan id ${VlanID}
  34. ip addr add ${HostIP} brd ${BroadcastIP} dev ${EthernetInterface}.${VlanID}
  35. ip link set dev ${EthernetInterface}.${VlanID} up
  36.  
  37. # macvlan bridge for communication between host & containers
  38. ip link add ${BridgeInterface}.${VlanID} link ${EthernetInterface}.${VlanID} type macvlan mode bridge
  39. ip addr add ${ContainerAccessIP} dev ${BridgeInterface}.${VlanID}
  40. ip link set ${BridgeInterface}.${VlanID} up
  41. ip route del ${ContainerNetwork}
  42. ip route add ${ContainerNetwork} dev ${BridgeInterface}.${VlanID}
  43. #### DON'T TOUCH HERE ANYTHING #######
Advertisement
Add Comment
Please, Sign In to add comment