如何更改 Raspbian PI 4 上无线连接的静态 IP 地址? [关闭]

Posted

技术标签:

【中文标题】如何更改 Raspbian PI 4 上无线连接的静态 IP 地址? [关闭]【英文标题】:How do I change the static IP address for wireless connection on Raspbian PI 4? [closed] 【发布时间】:2022-01-22 03:14:29 【问题描述】:

我正在使用 Raspberry Pi 4B 和 Raspbian Buster。我想更改树莓派的静态 IP 地址。这样我就可以通过 HotSpot 和 WiFi 远程连接到 Raspberry Pi。

我想更新 静态 IP 地址,只是为了通过 WiFi 连接到 Raspberry Pi。

我该如何解决这个问题?

【问题讨论】:

【参考方案1】:

要改变设备的静态ip地址,需要修改DHCP(Dynamic Host Configuration Protocol)客户端守护进程dhcpcd.conf

# To find the device's static IP address
# "wlan0": wireless connection
# "eth0": ethernet wired connection
hostname -I

# Find your router's Gateway IP address
ip r | grep default

# Find DNS (Domain Name System) IP address
sudo nano /etc/resolv.conf

编辑 dhcpcd.conf 文件以更新static ip_address:

sudo nano /etc/dhcpcd.conf

更改文件内容中的static ip_address并保存文件:

interface wlan0
static ip_address=192.168.1.123/24
static routers=192.168.1.254
static domain_name_servers=192.168.1.254

重启设备以应用 dhcpcd.conf 文件中的更改:

sudo reboot

设备开机后,再次查看设备的static ip_address

hostname -I
# Result: 192.168.1.123

【讨论】:

就我而言,我有两个 DNS。使用 sudo nano /etc/resolv.conf 我有静态 domain_name_servers=10.10.2.11 static domain_name_servers=10.10.2.13。那么dhcpcd.conf文件应该怎么做呢?像这样: interface wlan0 static ip_address=10.10.179.115/20 static routers=10.10.176.1 static domain_name_servers=10.10.2.11 interface wlan0 static ip_address=10.10.179.115/20 static routers=10.10.176.1 static domain_name_servers=10.10.2.13 另一个问题是,根据您的指示更改 dhcpcd.conf 文件后,我无法再连接到热点。在更改之前,我能够连接到热点。那么有什么帮助吗? 正如我分享的答案,您需要从您的wlan0 设置中更改static ip_address 字段并重新启动系统。 我已经完成了,但仍然无法连接到热点 您可能还需要更新热点设置:阅读this article。

以上是关于如何更改 Raspbian PI 4 上无线连接的静态 IP 地址? [关闭]的主要内容,如果未能解决你的问题,请参考以下文章

Opencv 3.4.3 gstreamer 在 Raspberry pi 3 上构建,最后一个 Raspbian 伸展不起作用

如何使用 QEMU 模拟 Raspberry Pi Raspbian?

sh 使用Raspbian在Raspberry Pi上安装mitmproxy的说明。

树莓派3-装系统-远程登录-无线连接-root获取

sh 在Raspberry Pi上安装tmux 2.0(Debian 7.8)Raspbian Wheezy

sh 在Raspberry Pi上安装tmux 2.0(Debian 7.8)Raspbian Wheezy