janneyabc 发表于 2015-4-11 10:17:14

KVM网络配置

  1、安装桥接工具





sudo apt-get install bridge-utils
sudo apt-get install uml-utilities
  2、编辑网络界面配置文件



sudo vi /etc/network/interfaces
  内容如下:



auto eth0
iface eth0 inet manual
address 192.168.1.38
netmask 255.255.255.0
gateway 192.168.1.254
dns-nameservers 202.102.152.3
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user mn
auto br0
iface br0 inet static
bridge_ports eth0 tap0
address 192.168.1.38
netmask 255.255.255.0
gateway 192.168.1.254
  3、配置网卡的网络参数



sudo ifconfig tap0 192.168.0.10 netmask 255.255.255.0 up
  4、系统的配置(连外网所必须)(如果只是虚拟机之间通信则不需要配置)
     开启了linux的ip转发功能,host可以当路由器用了。



sudo echo 1 > /proc/sys/net/ipv4/ip_forward
  打开NAT转发



sudo iptables -t nat -A POSTROUTING -j MASQUERADE
  
  
  
  
  
  
  
  
  
  
  
页: [1]
查看完整版本: KVM网络配置