【问题标题】:Yocto ifconfig not clean after a ifdown -a [closed]在 ifdown -a 之后 Yocto ifconfig 不干净 [关闭]
【发布时间】:2017-05-13 09:47:43
【问题描述】:

我在具有环回和 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

如果我在 DHCP 模式下配置 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 接口没有完全清理,这对我来说是个问题,因为我使用它的状态来管理我系统中的其他东西。

我准确地说我使用了添加 ifdown 脚本的包 resolvconf(在 DHCP 的情况下不使用)

cat /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}" || :  

你知道出了什么问题吗?

【问题讨论】:

    标签: networking yocto dhcp ifconfig


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 2016-08-14
      • 2014-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多