To be a better coder
分类: LINUX
2020-11-05 18:44:29
[root]# ip link add link eth0 name eth0.1 type vlan id 1
[root]# ip link add link eth0 name eth0.2 type vlan id 2
[root]# ip addr add 192.168.1.1/24 dev eth0.1 brd +
[root]# ip addr add 192.168.2.1/24 dev eth0.2 brd +
[root]# ip link set eth0.1 up
[root]# ip link set eth0.2 up
在eth0网络接口上增加两个vlan,并设置ip地址,然后启用两个虚拟接口,brd +表示广播地址后24位全部为1 (192.255.255.255)
[root]# ip link show
[root]# ip addr show
[root]# ip link delete eth0.1 type vlan
[root]# ip link delete eth0.2 type vlan