linux、android下網橋實現
阿新 • • 發佈:2019-02-08
linux下網橋實現:
1、安裝編譯安裝bridge-utils;
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
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