Skip to content

Instantly share code, notes, and snippets.

@durd
Created January 23, 2019 23:53
Show Gist options
  • Save durd/c4793c62a138b814197d560dd1801399 to your computer and use it in GitHub Desktop.
Save durd/c4793c62a138b814197d560dd1801399 to your computer and use it in GitHub Desktop.
vlan with systemd
# /lib/udev/rules.d/
# Allow rfkill for users in the netdev group
KERNEL=="rfkill", MODE="0664", GROUP="netdev"
# Handle allow-hotplug interfaces
SUBSYSTEM=="net", ACTION=="add|remove", RUN+="ifupdown-hotplug"
SUBSYSTEM=="net", RUN+="vlan-network-interface"
# /lib/udev/vlan-network-interface
#!/bin/sh
# vlan-network-interface - configure a network bridge
#
# This service checks whether a physical network device that has been added
# has VLAN defined in /etc/network/interfaces that should be brought up
set -e
if [ -z "$INTERFACE" ]; then
echo "missing \$INTERFACE" >&2
exit 1
fi
if ! which ifquery >/dev/null; then
exit 0
fi
if [ ! -x /etc/network/if-pre-up.d/vlan ]; then
exit 0
fi
mkdir -p /run/network
for IFACE in $(ifquery --list --allow auto); do
IF_VLAN_RAW_DEVICE=$(ifquery $IFACE | sed -n -e's/^vlan[_-]raw[_-]device: //p')
# Now that the environment is ready, call the pre-up script to create the vlan
export IFACE IF_VLAN_RAW_DEVICE
# Create the VLANs related to the interface
if [ "$IF_VLAN_RAW_DEVICE" = "$INTERFACE" ] || \
echo $IFACE | grep -q $INTERFACE; then
/etc/network/if-pre-up.d/vlan
fi
done
@durd
Copy link
Author

durd commented Jan 23, 2019

disable systemds networking.service.
still doesnt honor /etc/dhcp/dhclient.conf...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment