linux、android下网桥实现

来源:互联网 发布:淘宝评价添加小视频 编辑:程序博客网 时间:2024/05/30 19:34
linux下网桥实现:
1、安装编译安装bridge-utils;

apt-get install bridge-utils

2、配置网桥 
brctl addbr bridge
ifconfig eth0 down
ifconfig eth1 down
ifconfig eth0 0.0.0.0
ifconfig eth1 0.0.0.0
brctl addif bridge eth0
brctl addif bridge ath0
ifconfig br0 up

dhclient br0  (启动dhclient获取ip地址)


android下网桥实现,同时android层需要处理好dhcp进行ip获取,dns设置:

1、先按linux设置网桥;

2、按下面配置androidiptables;

iptables -A FORWARD-i eth0 -o eth1 -j ACCEPT

iptables -A FORWARD-i eth1 -o eth0 -j ACCEPT

iptables -D FORWARD 4                              /* 删除natctrl_FORWARD规则,FORWARD中的第4条规则  */

配置完成后,iptables–list看一下配置后的iptables FORWARD链为下面内容就对了

Chain FORWARD(policy ACCEPT)

target    prot optsource              destination        

oem_fwd   all  -- anywhere            anywhere           

fw_FORWARD all  -- anywhere            anywhere           

bw_FORWARD all  -- anywhere            anywhere           

ACCEPT    all  -- anywhere            anywhere           

ACCEPT    all  -- anywhere            anywhere   

0 0