Routes 路由表中的src字段不正确但有效
在运行ArchLinux的raspberry pi上,我的路由表有一个奇怪的问题Routes 路由表中的src字段不正确但有效,routes,hostname,archlinux,Routes,Hostname,Archlinux,在运行ArchLinux的raspberry pi上,我的路由表有一个奇怪的问题 greg@pi etc]$ uname -a Linux pi 3.6.11-2-ARCH+ #1 PREEMPT Mon Dec 31 23:00:25 UTC 2012 armv6l GNU/Linux 我有一个静态IP地址的pi设置。使用netcfg和net自动连线服务 我还使用nmbd服务作为samba的一部分,以允许我通过主机名ping设备 奇怪的是,我分配给设备的静态ip不是我通过主机名通信时收到回复
greg@pi etc]$ uname -a
Linux pi 3.6.11-2-ARCH+ #1 PREEMPT Mon Dec 31 23:00:25 UTC 2012 armv6l GNU/Linux
我有一个静态IP地址的pi设置。使用netcfg和net自动连线服务
我还使用nmbd服务作为samba的一部分,以允许我通过主机名ping设备
奇怪的是,我分配给设备的静态ip不是我通过主机名通信时收到回复的ip
查看路由表似乎表明存在以下问题:
[greg@pi ~]$ ip route show
default via 192.168.1.1 dev eth0
default via 192.168.1.1 dev eth0 metric 204
192.168.0.0/24 via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.20 metric 204
[greg@pi ~]$
我的界面设置:
[greg@pi ~]$ ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.3 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::ba27:ebff:fec9:1caf prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:c9:1c:af txqueuelen 1000 (Ethernet)
RX packets 1127 bytes 93818 (91.6 KiB)
RX errors 0 dropped 3 overruns 0 frame 0
TX packets 684 bytes 76203 (74.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ifb0: flags=130<BROADCAST,NOARP> mtu 1500
ether e2:bb:30:e7:d0:8a txqueuelen 32 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ifb1: flags=130<BROADCAST,NOARP> mtu 1500
ether 8a:e3:26:d4:38:b8 txqueuelen 32 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 20 bytes 1890 (1.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 1890 (1.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
现在,正如我所说,这个设置仍在运行。但我很困惑,想知道
a) 这实际上是如何工作的
b) 如何修复它
另外,看看我的日志(下面来自“everything.log”),我看到了更多关于dhcpcd的参考资料
Jan 1 01:00:09 pi dhcpcd[108]: eth0: rebinding lease of 192.168.1.20
Jan 1 01:00:10 pi dhcpcd[108]: eth0: acknowledged 192.168.1.20 from 192.168.1.1
Jan 1 01:00:10 pi dhcpcd[108]: eth0: checking for 192.168.1.20
Jan 1 01:00:14 pi dhcpcd[108]: eth0: leased 192.168.1.20 for 3600 seconds
但是,我没有这个过程的自定义配置。
任何关于我应该在哪里调试的建议都将不胜感激
更多细节:
树莓连接到一个edimax wifi usb加密狗,所以我也考虑到了这个接口。我一直在使用拱门页面作为指南
我安装了wireless_工具、dhcpcd(如果还没有的话,我想不起来)和netcfg。我还安装了net auto wired和net auto wireless,希望连接能够根据插入的连接正常工作
以下是相关的配置文件:
[greg@pi multi-user.target.wants]$ pwd
/etc/systemd/system/multi-user.target.wants
[greg@pi multi-user.target.wants]$ ls
cronie.service openntpd.service sshdgenkeys.service
dhcpcd@eth0.service remote-fs.target syslog-ng.service
net-auto-wired.service smbd.service
nmbd.service sshd.service
[greg@pi multi-user.target.wants]$
dhcpcd@eth0.service:
[greg@pi multi-user.target.wants]$ cat dhcpcd\@eth0.service
[Unit]
Description=dhcpcd on %I
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=forking
PIDFile=/run/dhcpcd-%I.pid
ExecStart=/usr/sbin/dhcpcd -q -w %I
ExecStop=/usr/sbin/dhcpcd -x %I
[Install]
Alias=multi-user.target.wants/dhcpcd@eth0.service
net-auto-wired.service:
[greg@pi multi-user.target.wants]$ cat net-auto-wired.service
[Unit]
Description=Provides automatic netcfg wired connection
[Service]
EnvironmentFile=/etc/conf.d/netcfg
ExecStart=/usr/bin/ifplugd -i $WIRED_INTERFACE -r /etc/ifplugd/netcfg.action -fIns
ExecStop=/usr/bin/netcfg iface-down $WIRED_INTERFACE
[Install]
WantedBy=multi-user.target
[greg@pi multi-user.target.wants]$
[greg@pi network.d]$ pwd
/etc/network.d
[greg@pi network.d]$ ls
ethernet-static examples interfaces wlan0-xxx
[greg@pi network.d]$ cat wlan0-xxx
CONNECTION='wireless'
DESCRIPTION='Automatically generated profile by wifi-menu'
INTERFACE='wlan0'
SECURITY='wpa'
ESSID=xxx
IP='dhcp'
KEY=xxx
[greg@pi network.d]$ cat ethernet-static
CONNECTION='ethernet'
DESCRIPTION='A basic static ethernet connection using iproute'
INTERFACE='eth0'
IP='static'
ADDR='192.168.1.3'
ROUTES=('192.168.0.0/24 via 192.168.1.1')
GATEWAY='192.168.1.1'
DNS=('192.168.1.1')
## For IPv6 autoconfiguration
#IP6=stateless
## For IPv6 static address configuration
#IP6='static'
#ADDR6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
#ROUTES6=('abcd::1234')
#GATEWAY6='1234:0:123::abcd'
[greg@pi network.d]$
[greg@pi log]$ cat /etc/dhcpcd.conf
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Inform the DHCP server of our hostname for DDNS.
hostname
# To share the DHCP lease across OSX and Windows a ClientID is needed.
# Enabling this may get a different lease than the kernel DHCP client.
# Some upstream DHCP servers may also require a ClientID, such as FRITZ!Box.
#clientid
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
noipv4ll
#static dns lookup address
#nohook resolv.conf
[greg@pi log]$
如果有什么我遗漏了,请让我知道,我会张贴它
systemctl报告的服务摘要:
[greg@pi ~]$ systemctl > services
[greg@pi ~]$ cat services
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys...t_misc.automount loaded active running Arbitrary Executable File Formats File System Automount Point
sys-devi...y-ttyAMA0.device loaded active plugged /sys/devices/dev:f1/tty/ttyAMA0
sys-devi...-net-eth0.device loaded active plugged ec00
sys-devi...mmcblk0p1.device loaded active plugged /sys/devices/platform/mmc_host/mmc0/mmc0:e624/block/mmcblk0/mmcblk0p1
sys-devi...mmcblk0p2.device loaded active plugged /sys/devices/platform/mmc_host/mmc0/mmc0:e624/block/mmcblk0/mmcblk0p2
sys-devi...k-mmcblk0.device loaded active plugged /sys/devices/platform/mmc_host/mmc0/mmc0:e624/block/mmcblk0
sys-devi...-net-ifb0.device loaded active plugged /sys/devices/virtual/net/ifb0
sys-devi...-net-ifb1.device loaded active plugged /sys/devices/virtual/net/ifb1
sys-devi...ttyprintk.device loaded active plugged /sys/devices/virtual/tty/ttyprintk
sys-module-configfs.device loaded active plugged /sys/module/configfs
sys-subs...ices-eth0.device loaded active plugged ec00
sys-subs...ices-ifb0.device loaded active plugged /sys/subsystem/net/devices/ifb0
sys-subs...ices-ifb1.device loaded active plugged /sys/subsystem/net/devices/ifb1
-.mount loaded active mounted /
boot.mount loaded active mounted /boot
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
proc-sys...infmt_misc.mount loaded active mounted Arbitrary Executable File Formats File System
sys-kernel-config.mount loaded active mounted Configuration File System
sys-kernel-debug.mount loaded active mounted Debug File System
tmp.mount loaded active mounted Temporary Directory
systemd-...ord-console.path loaded active waiting Dispatch Password Requests to Console Directory Watch
systemd-...ssword-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch
crond.service loaded failed failed LEGACY unit for "crond" rc script
cronie.service loaded active running Periodic Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
dhcpcd@eth0.service loaded active running dhcpcd on eth0
getty@tty1.service loaded active running Getty on tty1
hwclock.service loaded active exited LEGACY unit for "hwclock" rc script
net-auto-wired.service loaded active running Provides automatic netcfg wired connection
network.service loaded active exited LEGACY unit for "network" rc script
nmbd.service loaded active running Samba NetBIOS name server
openntpd.service loaded active running OpenNTP Daemon
rc-local.service loaded active exited /etc/rc.local Compatibility
smbd.service loaded active running Samba SMB/CIFS server
sshd.service loaded active running OpenSSH Daemon
syslog-ng.service loaded active running System Logger Daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-...es-setup.service loaded active exited Recreate Volatile Files and Directories
systemd-...-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-...sessions.service loaded active exited Permit User Sessions
systemd-...le-setup.service loaded active exited Setup Virtual Console
dbus.socket loaded active running D-Bus System Message Bus Socket
syslog.socket loaded active running Syslog Socket
systemd-initctl.socket loaded active listening /dev/initctl Compatibility Named Pipe
systemd-journald.socket loaded active running Journal Socket
systemd-shutdownd.socket loaded active listening Delayed Shutdown Socket
systemd-...d-control.socket loaded active listening udev Control Socket
systemd-udevd-kernel.socket loaded active running udev Kernel Socket
arch-daemons.target loaded active active Arch Daemons
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User
network.target loaded active active Network
remote-fs.target loaded active active Remote File Systems
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
syslog.target loaded active active Syslog
systemd-...iles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
67 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[greg@pi ~]$
有趣的是,我尝试禁用dhcpcd服务,正如Martin在下面的评论中所建议的,在确认它已禁用并重新启动后,我没有看到任何变化,Ping树莓显示了来自192.168.1.3的响应,这是不同的,但ip route show
产生了相同的结果。然后,我尝试禁用net自动连线
服务。我重新启动了raspberry,然后我认为我已经失去了对设备的访问(通过ssh的headless),因为我没有重新启用dhcpcd服务。有趣的是,我没有,我的ip地址现在是192.168.1.20
dhcpcd服务当前未运行:
[greg@pi log]$ systemctl | grep -i dhcp
[greg@pi log]$
因此,这告诉我,必须有一些其他的dhcp机制,我还不知道
查看systemctl并对eth0进行grepping:
[greg@pi log]$ systemctl -a --full | grep -i eth
sys-devices-platform-bcm2708_usb-usb1-1\x2d1-1\x2d1.1-1\x2d1.1:1.0-net-eth0.device loaded active plugged ec00
sys-subsystem-net-devices-eth0.device loaded active plugged ec00
LOAD = Reflects whether the unit definition was properly loaded.
[greg@pi log]$
我还不确定上述两项服务是什么,但它们是否与问题有关?问题的答案
a) 这实际上是如何工作的
是。从Arch wiki:
IP别名是将多个IP地址添加到网络接口的过程。这样,网络上的一个节点可以有多个到网络的连接,每个连接都有不同的用途
现在回答
b) 如何修复它
192.168.1.3
是您希望使用的ip,并且您希望它是静态的,这意味着192.168.1.20
是dhcpcd获得的ip,它也是根据您的/etc/systemd/system/multi-user.target.wants
文件夹的内容启动的服务。因此,通过禁用此服务,问题应该会消失。您可以(以root用户身份)运行
或
现在,如果您想使用USB加密狗,我建议您放弃net auto-wired
(以类似方式删除该服务),改用wicd
或networkmanager
,两者都可以配置为使用静态ip,并在第一个接口不存在时默认为另一个接口。而且它们更容易设置
最后,简单地使用dhcp为您的接口获取IP,并配置路由器或调制解调器以根据MAC地址分配固定IP不是一个坏主意。是否有可能运行
dhcpcd@
服务?运行systemctl | grep dhcpcd
查看它是否处于活动状态。您好,Martin,谢谢您的回复。是的,它是eth0.service的一部分,我想:[greg@pinetwork.d]$systemctl | grep dhcpcddhcpcd@eth0.service在eth0上加载了正在运行的活动dhcpcd
,但我也看到了这一点:[greg@pinetwork.d]$systemctl status dhcpcd dhcpcd.service-加载的所有接口上的dhcpcd:已加载(/usr/lib/systemd/system/dhcpcd.service;已禁用)活动:非活动(死)CGroup:name=systemd:/system/dhcpcd.service
很难预测问题是什么,但很明显这是一个无意的别名。如果你能一步一步地解释一下,你为配置你的网络所做的每一个动作。你复制、创建、修改了哪些文件,启用了哪些服务,运行了哪些命令,等等。这可能有助于我们了解这些问题e问题。嗨,马丁,谢谢你的详细回复,这无疑让我更接近问题的根源。这开始变得更有意义。不幸的是,我不得不使用我的ISP提供的路由器,它在接口和设置方面有点糟糕,这就是为什么我想在raspberry方面这样做。请查看更新的问题m说明。我未能看到“网络”的network.service旧版单元rc脚本,那么禁用该脚本并重新启用net auto wired.Bingo如何?问题的解决方案是按照您的建议编辑/etc/rc.conf并从守护进程列表中删除网络。据我所知,正确设置的系统不需要rc initscript系统,但我目前还不确定是否禁用。但是,我明白了算了!非常感谢你的帮助。
[greg@pi log]$ systemctl -a --full | grep -i eth
sys-devices-platform-bcm2708_usb-usb1-1\x2d1-1\x2d1.1-1\x2d1.1:1.0-net-eth0.device loaded active plugged ec00
sys-subsystem-net-devices-eth0.device loaded active plugged ec00
LOAD = Reflects whether the unit definition was properly loaded.
[greg@pi log]$
systemctl disable dhcpcd@eth0.service
rm /etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service