hil*_*t0n 5 networking dhcp ifconfig yocto
我在具有环回和 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
Run Code Online (Sandbox Code Playgroud)
如果我将 eth0 配置为 DHCP 模式,就会出现问题:
# /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
Run Code Online (Sandbox Code Playgroud)
在执行 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)
Run Code Online (Sandbox Code Playgroud)
但是,在 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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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}" || :
Run Code Online (Sandbox Code Playgroud)
您知道出了什么问题吗?
好吧,我终于找到了可以通过添加行来解决的问题
/sbin/resolvconf -d "${IFACE}.udhcpc" || :
Run Code Online (Sandbox Code Playgroud)
在文件 /etc/network/if-down.d/resolvconf 的末尾正确清理 udhcpc 创建的参数。
| 归档时间: |
|
| 查看次数: |
1467 次 |
| 最近记录: |