diff --git a/add_vlan.sh b/add_vlan.sh new file mode 100755 index 0000000..4eaad99 --- /dev/null +++ b/add_vlan.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +if [[ $UID != 0 ]]; then + echo "You need to be root to execute that script" + exit 1 +fi + +if [[ $# != 2 ]]; then + echo "You need to give at least 2 parameters ." + exit 1 +fi + +apt install vlan +modprobe 8021q +ip link add link $1 name $1.$2 type vlan id $2 +if [[ $2 == 10 ]]; then + ip addr add 192.168.0.217/24 dev $1.$2 +else + ip addr add 192.168.$2.217/24 dev $1.$2 +fi +ip link set up $1.$2 +