天天看點

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   

繼續閱讀