树莓派Raspberry Pi OS 设置静态IP地址 DNS #MMDVM Pi-Star

树莓派Raspberry Pi OS 设置静态IP地址



方法一(旧版本Raspberry Pi OS Debian10及以下)

编辑 /etc/network/interfaces ,修改eth0 网卡相关配置如下:

source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.101
netmask 255.255.255.0
network 192.168.0.1
gateway 192.168.0.1 

dns-nameservers 202.97.224.68202.97.224.69 #DNS 要指定,否则某些网络无法访问外网,参考https://blog.csdn.net/u013554213/article/details/78870408


方法二(新版本Raspberry Pi OS Debian11及以上)
编辑 /etc/dhcpcd.conf, 添加eth0 网卡相关配置如下:
interface eth0
static ip_address=192.168.0.103/24
static routers=192.168.0.103

注意:设置了固定固定IP后,更换路由器时,则无法连接网络,无法自动分配DHCP IP,请谨慎。此时你需要用键盘鼠标,HDMI屏幕进入修改。或者把路由器的IP设置为固定IP的同网段,才能访问。

对于Pi-Star,当连接不上指定WIFI 路由器后,会生成WiFi AP ,加入AP,再修改地址也可以的。
有线网卡:eth0
无线WIFI:wlan0,第二个WIFI: wlan1

全部参考:(Debian10为例)

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

pre-up iptables-restore < /etc/iptables.rules
pre-up ip6tables-restore < /etc/ip6tables.rules

#iface eth0 inet manual #必须屏蔽掉,不然有线网卡eth0静态IP设置无效

auto eth0
iface eth0 inet static
address 192.168.2.8 #有线网卡
netmask 255.255.255.0
network 192.168.2.1
gateway 192.168.2.1 #DNS  static domain_name_servers=8.8.8.8 8.8.4.4 可以改为与网关一样

auto wlan0
iface eth0 inet static
address 192.168.2.27 #WIFI0
netmask 255.255.255.0
network 192.168.2.1
gateway 192.168.2.1

auto wlan1
iface eth0 inet static
address 192.168.2.28 #USB-WIFI
netmask 255.255.255.0
network 192.168.2.1
gateway 192.168.2.1

allow-hotplug eth1
iface eth1 inet dhcp

allow-hotplug wwan0
iface wwan0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
wireless-power off

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
wireless-power off

iface wlan0_ap inet static
address 192.168.50.1
netmask 255.255.255.0
network 192.168.50.0
broadcast 192.168.50.255
wireless-power off

添加微信公众号【bi7jta73】,学习更多树莓派/Linux/MMDVM业余无线电知识

原文:https://liujinye.gitbook.io/openshift-docs/raspberry-pi/shu-mei-pai-raspberrypios-she-zhi-jing-tai-ip

MMDVM
MMDVM手机App进入TG46009数模互通测试组的方法
手机App下载使用