#!/bin/bash | |
# first argument is name of name-space | |
# second argument is name of interface to assign | |
# third argument is vlan | |
# fourth argument is IP to assing to interface | |
ip netns add $1 | |
ip link set dev $2 netns $1 | |
ip netns exec $1 ip link add link $2 name $2.$3 type vlan id $3 | |
ip netns exec $1 ifconfig $2.$3 $4 | |
ip netns exec $1 ifconfig $2 up | |
ip netns exec $1 ifconfig $2.$3 up |