linux、android下网桥实现

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
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值