ovs(openvswitch) 测试:物理机的一些配置
1. 安装包
# apt install openvswitch-switch
2.加载 openvswitch 模块
# lsmod | grep openvswicth
# modprobe openvswitch
# ovs-vsctl show
3. 创建 ovs bridge,并设置为 NAT 模式
# ovs-vsctl add-br virbr0
# ifconfig virbr0 192.168.100.1 up
#iptables -t nat -A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -j MASQUERADE
# dnsmasq --strict-order --except-interface=lo --interface=virbr0 --listen-address=192.168.100.1 --bind-interface --dhcp-range=192.168.100.2,192.168.100.254 --conf-file="" --pid-file=/var/run/qemu-dhcp-virbr0.pid --dhcp-leasefile=/var/run/qemu-dhcp-virbr0.leases --dhcp-no-override
# cat /etc/qemu-ifup
#!/bin/bash
switch=virbr0
ifconfig $1 up
ovs-vsctl add-port $switch $1
4. 恢复环境
# ovs-vsctl del-port virbr0 tap0
# ovs-vsctl del-br virbr0
# iptables -L -t nat --line-num
# iptables -t nat -D POSTROUTING 1 (数字1为上个命令展示的第一行)
# kill -9 <dnsmasq pid>
5. 启动虚拟机参数与普通的一样