【Raspberry pi 3】樹莓派3 設定固定ip

動機


樹莓派的無線網路真的很不穩(也有可能是我的ac66u 或是 附近2.4g頻道滿滿)
說實在讓我真的很困擾,有時候會掉封包導致line bot失常。
所以決定把他插實體線了
是說破百篇blog了耶,開心
上次同事說上網查powershell查到我的網誌。
那...為什麼不點一下廣告,放了六年才3美金阿...XD

方案


1. 設定linux裡面成為固定ip
2. 設定ac66u 鎖定MAC固定ip
已我這個懶人個性一定選2啊

過程


方案1 很簡單,用SSH連進樹莓以後
直接
root@raspberrypi:~# vi /etc/network/interfaces


找到eth0

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet dhcp

直接改成

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback


iface eth0 inet static
#your static IP
address 192.168.1.118
#your gateway IP
gateway 192.168.1.254
netmask 255.255.255.0
#your network address "family"
network 192.168.1.0
broadcast 192.168.1.255

然後重啟完工
root@raspberry:/etc/init.d/networking restart

不過我個人不喜歡這麼麻煩,所以決定用dhcp自動配
方法也很簡單
進ac66u的dhcp server設定裡面
直接鎖定mac address


驗證


直接拿ssh連進去,這邊用我最愛的工具 Xshell5
登入成功,驗證完成

留言