Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Set up a VLAN interface on an existing Synology network interface
- #
- # Copyright (c) 2023 Navigio UG (haftungsbeschränkt)
- # This software is provided 'as-is', without any express or implied warranty.
- # In no event will the authors be held liable for any damages arising from the use of this software.
- #
- # Permission is granted to anyone to use this software for any purpose, including
- # commercial applications, and to alter it and redistribute it freely.
- #
- # On Host this file needs to be placed into
- # /usr/local/etc/rc.d
- # insmod /lib/modules/8021q.ko
- ##### KONFIGURATION #####
- # Insert your changes here...
- EthernetInterface="eth0"
- BridgeInterface="mvlbr"
- VlanID="200"
- HostIP="192.168.200.2/24"
- BroadcastIP="192.168.200.255"
- ContainerAccessIP="192.168.200.254/32"
- ContainerNetwork="192.168.200.0/24"
- ##### KONFIGURATION #####
- #### DON'T TOUCH HERE ANYTHING #######
- # First delete possibly existing VLAN interfaces
- ip link del ${BridgeInterface}.${VlanID}
- ip link del ${EthernetInterface}.${VlanID}
- # Set up networking interface on VLAN ID
- # Prerequisite: VLAN has to be set up on router or L3 switch
- ip link add link ${EthernetInterface} name ${EthernetInterface}.${VlanID} type vlan id ${VlanID}
- ip addr add ${HostIP} brd ${BroadcastIP} dev ${EthernetInterface}.${VlanID}
- ip link set dev ${EthernetInterface}.${VlanID} up
- # macvlan bridge for communication between host & containers
- ip link add ${BridgeInterface}.${VlanID} link ${EthernetInterface}.${VlanID} type macvlan mode bridge
- ip addr add ${ContainerAccessIP} dev ${BridgeInterface}.${VlanID}
- ip link set ${BridgeInterface}.${VlanID} up
- ip route del ${ContainerNetwork}
- ip route add ${ContainerNetwork} dev ${BridgeInterface}.${VlanID}
- #### DON'T TOUCH HERE ANYTHING #######
Advertisement
Add Comment
Please, Sign In to add comment