Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # vim: set ts=8 sw=2 sts=2 et sta fileencoding=utf-8:
- # Define a VLAN interface in network interfaces file.
- # Usage:
- # iface foo inet <static|manual|dhcp|...>
- # vlan-master <interface>
- # vlan-id <N>
- # ...
- #
- # Optional:
- # vlan-protocol <802.1Q|802.1ad>
- # vlan-loose-binding <on|off>
- # vlan-gvrp <on|off>
- # vlan-mvrp <on|off>
- # vlan-ingress-qos-map FROM:TO FROM:TO...
- # vlan-egress-qos-map FROM:TO FROM:TO...
- # No assumptions are made about the vlan-id or master from the interface name.
- # You need to specify both vlan-id and vlan-master.
- [[ -z "${IF_VLAN_ID}" ]] && exit 0
- [[ -z "${IF_VLAN_MASTER}" ]] && exit 0
- run() {
- [[ "${VERBOSITY}" -ge 1 ]] && echo "$@"
- "$@"
- }
- case "${MODE}" in
- start)
- ip link add link "${IF_VLAN_MASTER}" name "${IFACE}" \
- type vlan id "${IF_VLAN_ID}" \
- ${IF_VLAN_PROTOCOL:+protocol ${IF_VLAN_PROTOCOL}} \
- ${IF_VLAN_LOOSE_BINDING:+loose_binding ${IF_VLAN_LOOSE_BINDING}} \
- ${IF_VLAN_GVRP:+gvrp ${GVRP}} \
- ${IF_VLAN_MVRP:+mvrp ${MVRP}} \
- ${IF_VLAN_INGRESS_QOS_MAP:+ingress-qos-map "${IF_VLAN_INGRESS_QOS_MAP}"} \
- ${IF_VLAN_EGRESS_QOS_MAP:+egress-qos-map "${IF_VLAN_EGRESS_QOS_MAP}"}
- ;;
- stop)
- ip link delete "${IFACE}"
- ;;
- *) echo 'Invalid mode:' "${MODE:-none}" >&2; exit 1 ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement