给树莓派设置固定IP

4,807 views次阅读
没有评论

如果要查看当前使用IP 可以输入 ifconfig

但这个是 动态获取 的IP ,为了使用方便设置一个固定IP 是必须的。

 

sudo vi /etc/network/interfaces

原文如下:

auto lo

 

iface lo inet loopback

iface eth0 inet dhcp

 

allow-hotplug wlan0

iface wlan0 inet manual

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

 

可以看见 eth0 是动态dhcp获取IP,下面将 iface eth0 inet dhcp 修改如下:

iface eth0 inet static

address 192.168.1.88

netmask 255.255.255.0

gateway 192.168.1.1

这样树莓派的网口固定IP 就改成了:192.168.1.88

 

那无线IP呢?下面接着将 iface default inet dhcp 修改如下:

iface default inet static

address 192.168.1.89

netmask 255.255.255.0

gateway 192.168.1.1

同样的wlan0 改为固定IP 192.168.1.89

记得注释掉 wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

 

修改后的 interfaces 内容如下:

auto lo

 

iface lo inet loopback

iface eth0 inet static

address 192.168.1.88

netmask 255.255.255.0

gateway 192.168.1.1

 

allow-hotplug wlan0

iface wlan0 inet manual

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet static

address 192.168.1.89

netmask 255.255.255.0

gateway 192.168.1.1

正文完
 0
HopoL
版权声明:本站原创文章,由 HopoL 于2016-01-16发表,共计876字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)

HopoL's Blog

文章搜索
最新评论
MickeyDee MickeyDee Thanks for the reply, according to Unraid Dev team, it may happen this year.
Metaldololity Metaldololity Whoa, that's really simple. You just save my time a lot. Thankyou!
HopoL HopoL Since you’ve got the backup, it’s actually pretty simple. Just restore the backup files to your new flash drive, then head over to the /config directory and edit the go file. Look for export UNRAID_GUID=xxxxxxxxxxxxxx and swap it with your new drive's GUID. That should do the trick!
Metaldololity Metaldololity Really apreciate for your fast respond, mate. I actually have the backup of the flashdrive (from regular unraid backup). The problem is, when i search on youtube tutorial about changing the failed flashdrive, the process need some sort of confirmation with an account in unraid (blacklist the old one -> whitelist the new one). Since i have a cracked unraid, i don't know how to register my new flashdrive as the correct one (and the system not asking me for the old failed flashdrive). Thanks in advance
HopoL HopoL Man, that's a tough spot to be in. Regularly backing up your /boot folder is super important for exactly this reason. If you don't have a backup and your flash drive is completely fried, your best bet is to Google some specific recovery guides or check the Unraid forums. There are ways to rebuild your config by identifying your parity and data drives, but it can be a bit of a process. Hope you can get it sorted!