xen中用ubuntu连接两个网桥

来源:互联网 发布:c语言求素数代码 编辑:程序博客网 时间:2024/05/16 18:18

作者: Automatic  出自: http://www.linuxdiyf.com
因为公司的需要,目前又追加了一个网段A:10.4.1.*/16,而公司原有域为B:10.2.1.*/16,为了使两个网段能够通信,本文的目的就在Ubuntu下设置路由
使两个网段能互相通信。
1、ubuntu机器设置为双网卡,分别连接两个网段。
#router@proxy:/etc/network$ sudo vi interfaces
dd
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 10.2.1.216
netmask 255.255.0.0
network 10.2.0.0
broadcast 10.2.255.255
gateway 10.2.1.218
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 211.93.80.129 211.94.65.97 211.98.4.1
auto eth1
iface eth1 inet static
address 10.4.1.216
netmask 255.255.0.0
network 10.4.0.0
broadcast 10.4.255.255
gateway 10.4.1.10
dns-nameservers 211.93.80.129 211.94.65.97
iface dsl-provider inet ppp
provider dsl-provider
2、打开包转发
编辑/etc/sysctl.conf

net.ipv4.ip_forward = 0
改成
net.ipv4.ip_forward = 1

 

 

首先转一篇别人的文章,

然后来说说我的做法:

1)需要在xen上建一个ubuntu的虚拟机,注意xen不是对所有的系统都支持,我装的是ubuntu8.04,需要两块网卡,分别连接两个网桥两个网卡的ip分别设为10.0.0.254和10.0.1.254

 

2)不知为什么我建的ubuntu没有配置脚本,这也就意味着我不能像前一篇那样用vif=["bridge=xenbr11,bridge=xenbr33"]的方式配置网桥连接了,可以采用libvirt工具,基于xml建立网桥,修改xml连接网桥,过程和配置文件差不多,不多说了

 

3)启动ubuntu之后用brctl show查看网桥连接状态,按预期设置无误

 

4)编辑/etc/sysctl.conf


net.ipv4.ip_forward = 0
改成
net.ipv4.ip_forward = 1

 

这步是关键,我的ubuntu中net.ipv4.ip_forward = 1是注释掉的,还原即可

重启ubuntu,ping测试成功!!

 

注意:每个domu的ip和子网掩码都不要填写错误,domu的网关填写对应网段的ubuntu网卡ip,比如10.0.0.20的网关为10.0.0.254,不然可能带来麻烦

原创粉丝点击