02-vlan 823 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. [ -x /sbin/vconfig ] || exit 0
  3. case "$IFACE" in
  4. vlan*)
  5. vconfig set_name_type VLAN_PLUS_VID_NO_PAD
  6. VLANID=`echo $IFACE|sed "s/vlan*//"`
  7. ;;
  8. eth*.*)
  9. vconfig set_name_type DEV_PLUS_VID_NO_PAD
  10. VLANID=`echo $IFACE|sed "s/eth[0-9][0-9]*\.*//g"`
  11. IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/\(eth[0-9][0-9]*\)\..*/\1/"`
  12. ;;
  13. *)
  14. exit 0
  15. ;;
  16. esac
  17. if [ "$IF_VLAN_RAW_DEVICE" != "" ]; then
  18. if ! grep -q "$IF_VLAN_RAW_DEVICE" /proc/net/dev
  19. then
  20. echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE"
  21. exit 1
  22. fi
  23. ip link set up dev $IF_VLAN_RAW_DEVICE
  24. vconfig add $IF_VLAN_RAW_DEVICE $VLANID
  25. if [ "$IF_MAC_ADDRESS" != "" ]
  26. then
  27. ip link set $IF_VLAN_RAW_DEVICE.$VLANID address $IF_MAC_ADDRESS
  28. fi
  29. ip link set up dev $IF_VLAN_RAW_DEVICE.$VLANID
  30. fi
  31. exit 0