summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/vlan-dhcp5
-rw-r--r--examples/vlan-static12
-rwxr-xr-xsrc/connections/vlan40
3 files changed, 57 insertions, 0 deletions
diff --git a/examples/vlan-dhcp b/examples/vlan-dhcp
new file mode 100644
index 0000000..8c6ad23
--- /dev/null
+++ b/examples/vlan-dhcp
@@ -0,0 +1,5 @@
+INTERFACE="eth0.55"
+VLAN_PHYS_DEV="eth0"
+VLAN_ID="55"
+CONNECTION="vlan"
+IP="dhcp"
diff --git a/examples/vlan-static b/examples/vlan-static
new file mode 100644
index 0000000..b7b9753
--- /dev/null
+++ b/examples/vlan-static
@@ -0,0 +1,12 @@
+INTERFACE="eth0.11"
+VLAN_PHYS_DEV="eth0"
+VLAN_ID="11"
+CONNECTION="vlan"
+IP="static"
+ADDR="192.168.0.100"
+NETMASK="255.255.255.0"
+GATEWAY="192.168.0.1"
+DNS=("192.168.0.2")
+HOSTNAME="myhost"
+DOMAIN="mydomain.com"
+SEARCH="mydomain.com"
diff --git a/src/connections/vlan b/src/connections/vlan
new file mode 100755
index 0000000..7b81e7f
--- /dev/null
+++ b/src/connections/vlan
@@ -0,0 +1,40 @@
+#! /bin/bash
+. /usr/lib/network/network
+
+vlan_up() {
+ local vlan_interface
+ load_profile "$1"
+
+ if [ -e /sys/class/net/$INTERFACE ]; then
+ report_fail "Interface $INTERFACE already exists."
+ exit 1
+ else
+ ip link set $VLAN_PHYS_DEV up
+ ip link add link $VLAN_PHYS_DEV name $INTERFACE type vlan id $VLAN_ID >/dev/null 2>&1
+ fi
+ bring_interface up "$INTERFACE"
+ "$CONN_DIR/ethernet" up "$1"
+ return 0
+}
+
+vlan_down() {
+ local vlan_interface
+ load_profile "$1"
+
+ "$CONN_DIR/ethernet" down "$1"
+ bring_interface down "$INTERFACE"
+ ip link delete $INTERFACE >/dev/null 2>&1
+ return 0
+}
+
+vlan_status() {
+ if [ -e /sys/class/net/$INTERFACE ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+vlan_$1 "$2"
+exit $?
+# vim: set ts=4 et sw=4: