pi@raspberrypi:~ $ sudo ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:91:46:91
inet6 addr: fe80::ca34:11e2:7331:b87d/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1086 errors:0 dropped:0 overruns:0 frame:0
TX packets:1086 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:83408 (81.4 KiB) TX bytes:83408 (81.4 KiB)
wlan0 Link encap:Ethernet HWaddr b4:ee:b4:87:3a:d1
inet addr:192.168.0.121 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::b6ee:b4ff:fe87:3ad1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:241947 errors:0 dropped:35834 overruns:0 frame:0
TX packets:225100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:185653893 (177.0 MiB) TX bytes:195708830 (186.6 MiB)
pi@raspberrypi:~ $ hostname -I
192.168.0.121 192.168.0.111
网络配置如下:
pi@raspberrypi:~ $ 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 lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.121
netmask 255.255.255.0
gateway 192.168.0.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
这个 192.168.0.111 是从哪里来的?
1
mazyi 2017-01-22 23:39:28 +08:00
去看看 hostname -i 的指令说明。
|
2
mingl0280 2017-01-23 10:02:03 +08:00 via Android
你 manual 又没配置内容,自动 dhcp 咯……
正确做法是 down 掉 eth0 |
3
holyzhou 2017-01-23 10:31:13 +08:00 1
再用 ip a 看眼当前网络状况,接着用 root 用户 journalctl |grep "IP" 看看 ip 地址是什么时候怎么分配的。
|
4
lenovo OP r#3 @holyzhou @mingl0280
看起来还是 wlan0 分配的 IP ,不知怎么停用这一个? pi@raspberrypi:~ $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether b8:27:eb:91:46:91 brd ff:ff:ff:ff:ff:ff inet6 fe80::ca34:11e2:7331:b87d/64 scope link tentative valid_lft forever preferred_lft forever 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b4:ee:b4:87:3a:d1 brd ff:ff:ff:ff:ff:ff inet 192.168.0.121/24 brd 192.168.0.255 scope global wlan0 valid_lft forever preferred_lft forever inet 192.168.0.111/24 brd 192.168.0.255 scope global secondary wlan0 valid_lft forever preferred_lft forever inet6 fe80::b6ee:b4ff:fe87:3ad1/64 scope link valid_lft forever preferred_lft forever |
5
lenovo OP r#3 @holyzhou
pi@raspberrypi:~ $ sudo journalctl |grep "IP" Jan 22 13:33:21 raspberrypi kernel: CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache Jan 22 13:33:21 raspberrypi kernel: Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000) Jan 22 13:33:21 raspberrypi kernel: SMP: Total of 4 processors activated (153.60 BogoMIPS). Jan 22 13:33:26 raspberrypi kernel: IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready Jan 22 13:33:27 raspberrypi kernel: IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready Jan 22 13:33:27 raspberrypi kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready Jan 22 13:33:28 raspberrypi avahi-daemon[493]: Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::b6ee:b4ff:fe87:3ad1. Jan 22 13:33:28 raspberrypi avahi-daemon[493]: New relevant interface wlan0.IPv6 for mDNS. Jan 22 13:33:28 raspberrypi avahi-daemon[493]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.0.121. Jan 22 13:33:28 raspberrypi avahi-daemon[493]: New relevant interface wlan0.IPv4 for mDNS. Jan 22 13:33:28 raspberrypi avahi-daemon[493]: Joining mDNS multicast group on interface eth0.IPv6 with address fe80::ca34:11e2:7331:b87d. Jan 22 13:33:28 raspberrypi avahi-daemon[493]: New relevant interface eth0.IPv6 for mDNS. Jan 22 13:33:28 raspberrypi avahi-daemon[493]: Registering new address record for 192.168.0.121 on wlan0.IPv4. Jan 22 13:33:29 raspberrypi dhcpcd[514]: wlan0: soliciting an IPv6 router Jan 22 13:33:35 raspberrypi avahi-daemon[493]: Registering new address record for 192.168.0.111 on wlan0.IPv4. Jan 22 13:33:41 raspberrypi dhcpcd[514]: wlan0: no IPv6 Routers available |
6
lenovo OP 解决了,静态 IP 要在 /etc/dhcpcd.conf 中配置,不要在 /etc/network/interfaces 中配置
|
7
holyzhou 2017-01-23 11:57:00 +08:00
虽然解决了 ,但是我印象中,静态地址就是在 interfaces 里面定义的,而且 dhcpcd 也应该是配置 dhcp 相关的内容吧,你再想想你有没有在图形界面中配置过 ip 地址之类的信息,这也可能导致你 wlan 获得两个 ip 地址。
|
8
lenovo OP r#7 @holyzhou 我没显示器,都是 ssh 进去配置的
/etc/network/interfaces 最上面有几行提示,之前没注意 pi@raspberrypi:~ $ 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' |