linux 网络接口 dummy KVM

Load the dummy interface module

modprobe dummy

Create a dummy interface called mynic0

ip link set name mynic0 dev dummy0

Set its MAC address

ifconfig mynic0 hw ether 00:22:22:dd:ee:ff

Add a tap device

ip tuntap add dev mytap0 mode tap user root

Create a bridge, and bridge to it mynic0 and mytap0

brctl addbr mybr0
brctl addif mybr0 mynic0
brctl addif mybr0 mytap0

Set an IP addresses to the bridge

ifconfig mybr0 192.168.100.1 netmask 255.255.255.0 up
ip addr add fd5d:12c9:2201:1::1/24 dev mybr0

Make sure all interfaces are up

ip link set mybr0 up
ip link set mynic0 up
ip link set mytap0 up

Set basic masquerading for both ipv4 and 6

iptables -I FORWARD -j ACCEPT
iptables -t nat -I POSTROUTING -s 192.168.100.0/24 -j MASQUERADE
ip6tables -I FORWARD -j ACCEPT
ip6tables -t nat -I POSTROUTING -s fd5d:12c9:2201:1::/64 -j MASQUERADE

你可能感兴趣的:(linux)