5

I created a Yocto image on a target which has the loopback and a eth0 network interfaces.

When I configure the /etc/network/interface with static IP the network down command works. After the command ifdown -a the ifconfig returns nothing.

My /etc/network/interface in static mode:

# /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

My problem comes if I configure the eth0 in DHCP mode:

# /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

After a ifup -a command, ifconfig return that:

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)

However, After a 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 returns the following:

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

The eth0 interface isn't cleaned completely and this is a problem for me since I use its status to manage others things in my system.

I precise I use the package resolvconf which add a ifdown script (not used in case of 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}" || :  

Have you an idea about what is going wrong ?

hilt0n
  • 376
  • 1
  • 10

1 Answers1

1

Ok I finally found the problem which can be fixed by adding the line

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

at the end of the file /etc/network/if-down.d/resolvconf to clean correctly the parameters created by udhcpc.

hilt0n
  • 376
  • 1
  • 10