$ sudo ip link add link eth0 name eth0.111 type vlan id 111
$ sudo ip addr add 192.168.111.1/24 brd + dev eth0.111
$ sudo ip link set up dev eth0.111
$ ip addr show dev eth0.111
7: eth0.111@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether da:8d:21:53:7a:b5 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.1/24 brd 192.168.111.255 scope global eth0.111
valid_lft forever preferred_lft forever
To show VLAN id in the output of ip command -details option is needed:
$ ip -details addr show dev eth0.111
7: eth0.111@eth0: mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether da:8d:21:53:7a:b5 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 0 maxmtu 65535
vlan protocol 802.1Q id 111 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 tso_max_size 65536 tso_max_segs 65535 gro_max_size 65536
inet 192.168.111.1/24 brd 192.168.111.255 scope global eth0.111
valid_lft forever preferred_lft forever
It is desirable to manage VLANs as Linux does:
To show VLAN id in the output of
ip
command-details
option is needed:In macOS could be translated into:
To remove the interface link (
ip link del eth0.111
in Linux) it is possible to useifconfig vlan111 destroy
.There are some difference between macOS and Linux for VLAN interfaces:
ifconfig <interface> vlan <tag> vlandev <iface>
command;ifconfig <interface> down
has no effect;