23 lines
447 B
Bash
Executable File
23 lines
447 B
Bash
Executable File
#!/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 <network_interface> <vlan_id>."
|
|
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
|
|
|