配置VM使用单独的VLAN
实际在部署虚拟化的时候我们往往都会把宿主机和VM各自的地址段单独规划。借助OpenWrt可以自己划分一下vlan。OpenWrt上设置vlan tag可以参考之前的文章。比如我的network配置文件,划分了3个VLAN(其实最好不要使用vlan 0),非默认vlan里每个lan口都是打了vlan tag: config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config interface 'lan' option ifname 'eth1.0' option type 'bridge' option proto 'static' option ipaddr '10.0.1.1' option netmask '255.255.255.0' config interface 'lan1' option ifname 'eth1.1' option type 'bridge' option proto 'static' option ipaddr '10.1.1.1' option netmask '255.255.255.0' config interface 'lan2' option ifname 'eth1.2' option type 'bridge' option proto 'static' option ipaddr '10.2.1.1' option netmask '255.255.255.0' config interface 'wan' option ifname 'eth0' config switch 'eth1' option reset '1' option enable_vlan '1' config switch_vlan option device 'eth1' option vlan '0' option ports '0 1 2t 5*' config switch_vlan option device 'eth1' option vlan '1' option ports '0t 1t 2t 5*' config switch_vlan option device 'eth1' option vlan '2' option ports '0t 1t 2t 5*' config interface 'wwan' option proto 'dhcp' 其他还需要修改好dhcp和firewall配置文件(可以简单参考之前的文章)。在自己笔记本上测试的,把有线网卡eth0加了vlan 2,把没有eth0放到br0网桥,eth0.2放到了br2。测试dhcp br0和br2分别获取到IP。 ...