我的路由表在我的樹莓派運行拱linux上有一個奇怪的問題。不正確,但在路由表中工作的src字段
[email protected] 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和網絡自動有線服務。
我也使用nmbd服務作爲samba的一部分,允許我通過主機名ping設備 奇怪的是,我分配設備的靜態ip不是我從我通信時收到回覆的ip由主機名。
望着路由表似乎暗示問題:
[[email protected] ~]$ 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
[[email protected] ~]$
我的接口設置:
[[email protected] ~]$ 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
從網絡上的另一臺電腦我已經驗證這兩個IP地址是指在同一界面(他們有相同的物理地址)。通信工作的
例子:
[2013-01-22 00:37.47] ~
[GKuhn.GKUHN-L01] ? ping pi
Pinging pi [192.168.1.20] with 32 bytes of data:
Reply from 192.168.1.20: bytes=32 time=36ms TTL=64
Reply from 192.168.1.20: bytes=32 time=7ms TTL=64
Reply from 192.168.1.20: bytes=32 time=3ms TTL=64
Reply from 192.168.1.20: bytes=32 time=2ms TTL=64
Ping statistics for 192.168.1.20:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 36ms, Average = 12ms
[2013-01-22 00:37.54] ~
[GKuhn.GKUHN-L01] ? ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time=2ms TTL=64
Reply from 192.168.1.3: bytes=32 time=2ms TTL=64
Reply from 192.168.1.3: bytes=32 time=2ms TTL=64
Reply from 192.168.1.3: bytes=32 time=26ms TTL=64
Ping statistics for 192.168.1.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 26ms, Average = 8ms
現在,就像我說的這個設置是仍在工作。但我很困惑,想知道 a)這實際上是如何工作的 b)如何修復它
P.S.看着我的日誌(以下來自「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
但是我對這個過程中沒有自定義配置。 任何建議我應該在哪裏尋找調試這將不勝感激。
一些細節: 樹莓爲連接到wifi的EDIMAX USB加密狗,所以我已經將它設置在考慮這個接口也是如此。我一直在使用拱門Wireless Setup作爲指導。
我安裝了wireless_tools,dhcpcd(如果它已經不是我不記得了)和netcfg。我也裝淨自動有線和淨自動無線,希望的連接將只是工作具體取決於在被插入
下面是相關的配置文件:
[[email protected] multi-user.target.wants]$ pwd
/etc/systemd/system/multi-user.target.wants
[[email protected] multi-user.target.wants]$ ls
cronie.service openntpd.service sshdgenkeys.service
[email protected] remote-fs.target syslog-ng.service
net-auto-wired.service smbd.service
nmbd.service sshd.service
[[email protected] multi-user.target.wants]$
的dhcpcd @ eth0.service:
[[email protected] 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/[email protected]
淨自動wired.service:
[[email protected] 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
[[email protected] multi-user.target.wants]$
[[email protected] network.d]$ pwd
/etc/network.d
[[email protected] network.d]$ ls
ethernet-static examples interfaces wlan0-xxx
[[email protected] network.d]$ cat wlan0-xxx
CONNECTION='wireless'
DESCRIPTION='Automatically generated profile by wifi-menu'
INTERFACE='wlan0'
SECURITY='wpa'
ESSID=xxx
IP='dhcp'
KEY=xxx
[[email protected] 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'
[[email protected] network.d]$
[[email protected] 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
[[email protected] log]$
如果T這裏是我省略的任何內容,請讓我知道,我會發布它。
通過systemctl報道服務內容摘要:
[[email protected] ~]$ systemctl > services
[[email protected] ~]$ 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
[email protected] loaded active running dhcpcd on eth0
[email protected] 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'.
[[email protected] ~]$
有趣的是我試圖禁用的dhcpcd服務爲馬丁評價和確認,這是殘疾人和重新啓動後,下面的建議,我看不出有什麼變化,以及查驗覆盆子顯示出192.168.1.3的不同,但是ip route show
產生了相同的結果。然後我嘗試禁用net-auto-wired
服務。我重新啓動了覆盆子,然後我認爲我已經失去了訪問設備的權限(通過ssh無法訪問),因爲我沒有重新啓用dhcpcd服務。有趣的是我沒有和我的IP地址現在是192.168.1.20。
的dhcpcd服務目前尚未運行:
[[email protected] log]$ systemctl | grep -i dhcp
[[email protected] log]$
因此這告訴我,必須有一些其他的DHCP機制,我還沒有意識到的。在systemctl
尋找和grepping爲eth0:
[[email protected] 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.
[[email protected] log]$
我不知道,只是還沒有什麼上述2個服務,但能將它們相關的問題?
是否有'dhcpcd @'服務運行的機會?運行'systemctl | grep dhcpcd'來查看它是否處於活動狀態。 –
嗨馬丁,謝謝你的回覆。是的,它是eth0.service的一部分,我認爲:'[greg @ pi network.d] $ systemctl | grep dhcpcd [email protected]加載主動運行dhcpcd在eth0'但是我也看到:'[greg @ pi network.d] $ systemctl status dhcpcd dhcpcd.service - 所有接口上的dhcpcd 加載:加載(/ usr /lib/systemd/system/dhcpcd.service; disabled) Active:inactive(dead) CGroup:name = systemd:/system/dhcpcd.service ' –
很難預測問題是什麼,但顯然是無意的走樣。如果你可以一步一步解釋,你爲配置網絡所做的每一個動作。您複製,創建,修改了哪些文件,啓用了哪些服務,運行了哪些命令等等。它可以幫助我們解決問題。 –