我已经浏览过互联网(和 StackExchange ;) ),但尚未找到可行的解决方案。所以(又一个)关于无效网络设置的问题 :)
我不明白,为什么我的有线接口(在此系统上称为 end0,而不是 eth0)不使用配置的静态 IP 地址(192.168.57.222),而是使用其他 IP 地址(192.168.57.45)。对于我的无线接口 wlan0(192.168.57.223),它可以正常工作。
有人可以看看我的设置和输出并告诉我哪里出了问题吗?
分配的IP地址:
~# hostname -I
192.168.57.45 192.168.57.223 [ipv6-address]
ifconfig 的输出
~# ifconfig
end0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC> mtu 1500
inet 192.168.57.45 netmask 255.255.255.0 broadcast 192.168.57.255
inet6 XXX prefixlen 64 scopeid 0x20<link>
inet6 XXX prefixlen 64 scopeid 0x0<global>
ether txqueuelen 1000 (Ethernet)
RX packets 145 bytes 18385 (17.9 KiB)
RX errors 0 dropped 50 overruns 0 frame 0
TX packets 81 bytes 12484 (12.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Lokale Schleife)
RX packets 21 bytes 2432 (2.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21 bytes 2432 (2.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.57.223 netmask 255.255.255.0 broadcast 192.168.57.255
ether xx:xx:xx:xx:xx:xy txqueuelen 1000 (Ethernet)
RX packets 3764 bytes 363905 (355.3 KiB)
RX errors 0 dropped 2971 overruns 0 frame 0
TX packets 272 bytes 32838 (32.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
接口文件为空,取消注释此处的 end0 设置不会改变行为:
~# cat /etc/network/interfaces
# 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 end0
#allow-hotplug end0
#iface end0 inet static
# address 192.168.57.222
# netmask 255.255.255.0
# gateway 192.168.57.1
# dns-domain my.domain
# dns-nameservers 192.168.57.6
dhcpcd.conf(无注释)。ipv6 应该可以避免我在互联网上遇到的问题。根据我对手册页的理解,nodhcp 应该“不与 dhcp 对话”,rebind 应该重新读取配置并在发生更改时重新启动服务。
~# cat /etc/dhcpcd.conf
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
hostname
clientid
#duid
persistent
option rapid_commit
option interface_mtu
#option ntp_servers
require dhcp_server_identifier
slaac private
#my changes:
noipv6rs
noipv6
nodhcp
rebind
interface end0
static ip_address=192.168.57.222/24
static routers=192.168.57.1
static domain_name_servers=192.168.57.1
static domain_search=my.domain
interface wlan0
static ip_address=192.168.57.223/24
static routers=192.168.57.1
static domain_name_servers=192.168.57.6
static domain_search=my.domain
服务状态:
~# service dhcpcd status
○ dhcpcd.service - DHCP Client Daemon
Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; preset: enabled)
Active: inactive (dead)
Docs: man:dhcpcd(8)
~# service networking status
○ networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; disabled; preset: enabled)
Active: inactive (dead)
Docs: man:interfaces(5)
我的发行版设置
~# lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm