Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。












想改善这个问题吗?更新问题,以使为on-topic

2年前关闭。



Improve this question





我在具有环回和eth0网络接口的目标上创建了Yocto映像。

当我用静态IP配置/ etc / network / interface时,network down命令起作用。在命令ifdown -a之后,ifconfig不返回任何内容。

我的/ etc / network / interface处于静态模式:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# Main wired interface
auto eth0
iface eth0 inet static
  address 192.168.1.10
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 192.168.1.1


如果在eth0模式下配置eth0,会出现我的问题:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# Main wired interface
auto eth0
iface eth0 inet dhcp


在ifup -a命令之后,ifconfig返回:

eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          inet addr:192.168.1.133  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: <ipv6 address> Scope:Link
          inet6 addr: <ipv6 address> Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:553 errors:0 dropped:106 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:70121 (68.4 KiB)  TX bytes:11022 (10.7 KiB)
          Interrupt:33

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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:140 (140.0 B)  TX bytes:140 (140.0 B)


但是,在ifdown -a -v之后

run-parts /etc/network/if-down.d
ifconfig lo 127.0.0.1 down
run-parts /etc/network/if-post-down.d

run-parts /etc/network/if-down.d
kill `cat /var/run/udhcpc.eth0.pid` 2>/dev/null
ifconfig eth0 down
run-parts /etc/network/if-post-down.d


ifconfig返回以下内容:

eth0      Link encap:Ethernet  HWaddr fc:c2:3d:0d:bb:93
          inet6 addr: fe80::fec2:3dff:fe0d:bb93/64 Scope:Link
          inet6 addr: 2a02:1205:c69a:b970:fec2:3dff:fe0d:bb93/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1304 errors:0 dropped:272 overruns:0 frame:0
          TX packets:158 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:148500 (145.0 KiB)  TX bytes:16490 (16.1 KiB)
          Interrupt:33


eth0接口没有完全清除,这对我来说是个问题,因为我使用它的状态来管理系统中的其他内容。

我精确地说,我使用的软件包resolvconf添加了一个ifdown脚本(在DHCP中不使用)

猫/etc/network/if-down.d/resolvconf:

#!/bin/sh
#
# ifdown hook script for resolvconf
#
# This file is part of the resolvconf package.
#

[ -x /sbin/resolvconf ] || exit 0

case "$ADDRFAM" in
  inet|inet6) :      ;;
  *)          exit 0 ;;
esac

/sbin/resolvconf -d "${IFACE}.${ADDRFAM}" || :


您知道发生了什么问题吗?

最佳答案

好吧,我终于找到了可以通过添加行来解决的问题

/sbin/resolvconf -d "${IFACE}.udhcpc" || :


在文件/etc/network/if-down.d/resolvconf的末尾以正确清除udhcpc创建的参数。

关于networking - Yocto ifconfig在ifdown -a后不干净,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43951652/

10-13 06:41