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

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

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

我该如何解决这个问题?

【问题讨论】:

    标签: raspberry-pi static-ip-address


    【解决方案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
    猜你喜欢
    • 2017-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 2018-06-04
    • 1970-01-01
    • 2014-10-01
    • 2016-03-18
    相关资源
    最近更新 更多