我嘗試配置無線靜態 IP,到目前為止我發現的所有內容都是指乙太網路連接。我找到的一份有用的指南是:
http://www.sudo-juice.com/how-to-set-a-static-ip-in-ubuntu-the-proper-way/
到目前為止,我已將其寫入 /etc/network/interfaces 中:
iface eth0 inet static
address 192.168.0.108
netmask 255.255.255.0
gateway 192.168.1.1
如何修改它以獲得無線靜態IP?
編輯:
更改eth0
為wlan0
,但是當我重新啟動網路時,我無法連接到互聯網。
iface wlan0 inet static
address 192.168.0.108
netmask 255.255.255.0
gateway 192.168.1.1
ifconfig
更改後我的輸出是:
eth0 Link encap:Ethernet HWaddr f0:76:1c:74:9d:e3
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10049 errors:0 dropped:0 overruns:0 frame:0
TX packets:10049 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:923248 (923.2 KB) TX bytes:923248 (923.2 KB)
wlan0 Link encap:Ethernet HWaddr ac:b5:7d:e9:1a:79
inet addr:192.168.0.108 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:125998 errors:0 dropped:0 overruns:0 frame:0
TX packets:78544 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:163553553 (163.5 MB) TX bytes:9362435 (9.3 MB)
檢查我的路由(已wlan0
註解掉)並得到以下結果:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0
答案1
您的介面 wlan0 無法正確連接 192.168。0.108 給定網關 192.168。1.1.其中之一是不正確的。我建議您檢查同一網路上的其他裝置以驗證這些詳細資訊。
此外,任何無線介面都需要網路名稱和 WPA 金鑰才能關聯。我建議你的/etc/網路/接口文件修改為:
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 192.168.1.108
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8
wpa-ssid <your_network>
wpa-psk <your_key>
重啟介面:
sudo ifdown wlan0 && sudo ifup -v wlan0
查看:
ping -c3 www.ubuntu.com
當然,請替換上面您已驗證的詳細資訊。