樹莓派自帶一個網口(eth0), 我買了一個EDUP 8188CUS 垃圾無線網卡(說它垃圾是因為默認無法啟動監聽模式,得重編譯核,很折騰)
eth0口我想讓它連接 內網1 (192.168.2.0)
wlan1口我想讓它連接 內網2 (192.168.1.0)
是這樣配置 /etc/network/interfaces 的
auto lo iface lo inet loopback iface eth0 inet static address 192.168.2.166 netmask 255.255.255.0 gateway 192.168.2.1 auto wlan1 allow-hotplug wlan1 iface wlan1 inet dhcp wpa-ssid "wifihotsphot" wpa-psk "xxxxx"
sudo service networking restart 重啟之后
只有wlan1 連接上無線網了,並且獲得ip為 inet addr:192.168.1.156
但eth0 連沒有獲得ip,日了狗了,這是啥原因,我都給它配置了靜態ip了,居然不生效?
google之后發現有人和我遇到類似的問題,他是情況是 eth0 有ip, wlan0 無ip, 正好和我相反
他的解決辦法就是再執行下邊兩條命令:
sudo ifplugd eth0 --kill
sudo ifup wlan0
我正好和他相反,所以我的情況是:
sudo ifplugd wlan0 --kill
sudo ifup eth0
為了讓它每次自動生效,得加入到 /etc/rc.local 中
參考連接:
http://raspberrypi.stackexchange.com/questions/8851/setting-up-wifi-and-ethernet