This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: dhclient does not start automatically

Part Number: AM5728


Tool/software: Linux

Hello,

We are using Yocto based build system and we have recently started using /etc/network/interface file to manage our network. Main aim to use this file is to have automatic dhcp invocation and IP allocation when interface file is modified respectively. We have dhclient as the DHCP client. Previously we used to run the dhclient manually through our application whenever there was new network configuration updated. 

I know having an interface file, dhclient can work automatically and systemd can invoke it whenever required. In our case, dhclient is not invoking automatically (neither at bootup nor at interface file change), if we manually run the dhclient wlan0 command, then only it will retrieve an IP address from the DHCP server. We only need it for wlan0 interface, we don't have an ethernet.

I have also attached the interface file for the clarification below:

interface file for dynamic IP allocation:

auto lo
iface lo inet loopback

auto can0
iface can0 inet manual
pre-up /sbin/ip link set $IFACE type can bitrate 125000
pre-up ip link set $IFACE type can restart-ms 1000
up /sbin/ifconfig $IFACE up
down /sbin/ifconfig $IFACE down

auto can1
iface can1 inet manual
pre-up /sbin/ip link set $IFACE type can bitrate 125000
pre-up ip link set $IFACE type can restart-ms 1000
up /sbin/ifconfig $IFACE up
down /sbin/ifconfig $IFACE down

auto wlan0
iface wlan0 inet dhcp
post-up systemctl start wpa_supplicant
post-down systemctl stop wpa_supplicant

interface file for static IP allocation:

auto wlan0
iface wlan0 inet static
address 192.168.180.111
netmask 255.255.255.0
gateway 192.168.180.1
dhcp 0

Ultimate goal is to have dhclient work automatically as what it supposed to do. I would appreciate a prompt response.

Thanks,

Divyeshkumar 

  • Hi Divyeshkumar,

    Could you remove or comment wlan0 static configuration from /etc/network/interfaces file? Share the result please.

    BR
    Tsvetolin Shulev
  • HI Shulev,

    Thank you for the prompt response. The file I attached above is not a single file. Interface file for dynamic IP config is different and interface file for static IP config is different. I just replace those files as per the requirement. That means, if I am configured for the dynamic IP config my interface file would only be:

    auto lo
    iface lo inet loopback

    auto can0
    iface can0 inet manual
    pre-up /sbin/ip link set $IFACE type can bitrate 125000
    pre-up ip link set $IFACE type can restart-ms 1000
    up /sbin/ifconfig $IFACE up
    down /sbin/ifconfig $IFACE down

    auto can1
    iface can1 inet manual
    pre-up /sbin/ip link set $IFACE type can bitrate 125000
    pre-up ip link set $IFACE type can restart-ms 1000
    up /sbin/ifconfig $IFACE up
    down /sbin/ifconfig $IFACE down

    auto wlan0
    iface wlan0 inet dhcp
    post-up systemctl start wpa_supplicant
    post-down systemctl stop wpa_supplicant

     

    Thanks,

    Divyeshkumar

  • Divyeshkumar,

    OK, now I understand your configuration. Could you give more info about your Linux distribution - is it Processor SDK or some other Linux and which Kernel version using?
    I would like to ask you few additional question necessary about issue investigation.
    Are you observe some error messages in the console or int the kernel log ("dmesg" command output)?
    Could you post output of "iwconfig" command?
    Also try the following wlan0 configuration in /etc/network/interfaces file

    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet dhcp
          wpa-ssid <YOUR_SSID>
          wpa-psk <YOUR_PWD>

    BR
    Tsvetolin Shulev

  • Hi Shulev,

    It is not a processor SDK, It is custom Yocto based linux. The linux we are using is "Linux version 4.4.52".

    I don't see any error message or log in kernel boot-up, here's the dmesg output:

    ________________________________________________________________________________________________
    [ 4.774628] hub 2-0:1.0: USB hub found
    [ 4.775330] hub 2-0:1.0: 1 port detected
    [ 4.808921] EXT4-fs (mmcblk0p7): mounted filesystem with ordered data mode. Opts: (null)
    [ 4.809368] EXT4-fs (mmcblk0p6): mounted filesystem with ordered data mode. Opts: (null)
    [ 4.993071] (stk) :sleep command in scr
    [ 5.178900] systemd-journald[115]: Received request to flush runtime journal from PID 1
    [ 5.198524] random: nonblocking pool is initialized
    [ 5.416784] cfg80211: World regulatory domain updated:
    [ 5.416794] cfg80211: DFS Master region: unset
    [ 5.416799] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
    [ 5.416807] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
    [ 5.416813] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
    [ 5.416820] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
    [ 5.416826] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
    [ 5.416833] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
    [ 5.416839] cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
    [ 5.416845] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    [ 5.416851] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
    [ 5.819024] wl18xx_driver wl18xx.2.auto: Direct firmware load for ti-connectivity/wl1271-nvs.bin failed with error -2
    [ 5.954019] (stc): add_channel_to_table: id 4
    [ 5.954036] (stc): add_channel_to_table: id 2
    [ 5.954044] (stc): add_channel_to_table: id 3
    [ 6.074576] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
    [ 6.085801] usb 2-1: New USB device found, idVendor=0451, idProduct=8140
    [ 6.085813] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
    [ 6.088477] PVR_K: UM DDK-(3699939) and KM DDK-(3699939) match. [ OK ]
    [ 6.095078] hub 2-1:1.0: USB hub found
    [ 6.095645] hub 2-1:1.0: 4 ports detected
    [ 6.138718] usb 1-1: new high-speed USB device number 2 using xhci-hcd
    [ 6.186199] wlcore: wl18xx HW: 183x or 180x, PG 2.2 (ROM 0x11)
    [ 6.202743] wlcore: loaded
    [ 6.230180] (stc): remove_channel_from_table: id 3
    [ 6.230193] (stc): remove_channel_from_table: id 2
    [ 6.230201] (stc): remove_channel_from_table: id 4
    [ 6.230206] (stc): all chnl_ids unregistered
    [ 6.230228] (stk) :ldisc_install = 0
    [ 6.232520] (stc): st_tty_close
    [ 6.251884] usb 1-1: New USB device found, idVendor=0451, idProduct=8142
    [ 6.251896] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=1
    [ 6.251903] usb 1-1: SerialNumber: A30E20718FAC
    [ 6.270675] hub 1-1:1.0: USB hub found
    [ 6.270753] hub 1-1:1.0: 4 ports detected
    [ 6.423027] c_can_platform 4ae3c000.can can0: setting BTR=1c09 BRPE=0000
    [ 6.467241] c_can_platform 48480000.can can1: setting BTR=1c09 BRPE=0000
    [ 7.144730] wlcore: PHY firmware version: Rev 8.2.0.0.240
    [ 7.258073] wlcore: firmware booted (Rev 8.9.0.0.75)
    [ 7.291792] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
    [ 14.258767] (stc): chnl_id list empty :4
    [ 14.258780] (stk) : st_kim_start
    [ 14.365632] (stk) :ldisc_install = 1
    [ 14.417069] (stc): st_tty_open
    [ 14.417132] (stk) :line discipline installed
    [ 14.417591] (stk) :ti-connectivity/TIInit_11.8.32.bts
    [ 14.420574] (stk) :change remote baud rate command in firmware
    [ 14.420581] (stk) :skipping the wait event of change remote baud
    [ 14.429181] EXT4-fs (mmcblk0p5): re-mounted. Opts: (null)
    [ 14.542172] EXT4-fs (mmcblk0p5): re-mounted. Opts: (null)
    [ 14.619670] (stk) :sleep command in scr
    [ 14.977399] EXT4-fs (mmcblk0p5): re-mounted. Opts: (null)
    [ 15.085900] EXT4-fs (mmcblk0p5): re-mounted. Opts: (null)
    [ 15.120940] (stk) :sleep command in scr
    [ 16.225582] (stc): add_channel_to_table: id 4
    [ 16.225596] (stc): add_channel_to_table: id 2
    [ 16.225605] (stc): add_channel_to_table: id 3
    [ 28.158380] wlan0: authenticate with 20:4e:7f:97:af:b2
    [ 28.174185] wlan0: send auth to 20:4e:7f:97:af:b2 (try 1/3)
    [ 28.202654] wlan0: authenticated
    [ 28.205333] wlan0: associate with 20:4e:7f:97:af:b2 (try 1/3)
    [ 28.210296] wlan0: RX AssocResp from 20:4e:7f:97:af:b2 (capab=0x431 status=0 aid=2)
    [ 28.233849] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
    [ 28.234378] wlan0: associated
    [ 28.288695] wlcore: Association completed.
    _________________________________________________________________________________________________

    After it got connected to one of our AP, this is the ifconfig output for wlan0:
    _________________________________________________________________________________________________
    wlan0 Link encap:Ethernet HWaddr a8:1b:6a:8d:20:8d
    inet6 addr: fe80::aa1b:6aff:fe8d:208d/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:2 errors:0 dropped:0 overruns:0 frame:0
    TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:306 (306.0 B) TX bytes:1042 (1.0 KiB)
    _________________________________________________________________________________________________

    Here's the output of "ip addr":
    _________________________________________________________________________________________________
    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: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc fq_codel state UNKNOWN group default qlen 10
    link/can
    3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc fq_codel state UNKNOWN group default qlen 10
    link/can
    4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0
    5: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether a8:1b:6a:8d:20:8d brd ff:ff:ff:ff:ff:ff
    inet6 fe80::aa1b:6aff:fe8d:208d/64 scope link
    valid_lft forever preferred_lft forever
    _________________________________________________________________________________________________

    Output of "iw wlan0 link":

    Connected to 20:4e:7f:97:af:b2 (on wlan0)
    SSID: NETGEAR
    freq: 2422
    RX: 938 bytes (10 packets)
    TX: 1227 bytes (12 packets)
    signal: -21 dBm
    tx bitrate: 65.0 MBit/s MCS 7

    bss flags: short-preamble short-slot-time
    dtim period: 2
    beacon int: 100

    Output of "iwconfig":

    wlan0 no wireless extensions.

    sit0 no wireless extensions.

    lo no wireless extensions.

    can0 no wireless extensions.

    can1 no wireless extensions.


    I have tried modifying the interface file as you have suggested already, it didn't seem to work either.

    Thanks,
    Divyeshkumar
  • Hi Shulev,

    Do we have any update?

    Thanks,

    Divyeshkumar

  • Hello,

    Refer [1], to enable the service by default.
    systemctl enable dhcpcd.service
    systemctl start dhcpcd.service
    And from next boot onwards it should start by default.


    [1] wiki.archlinux.org/.../dhcpcd

    Cheers,
    --Prabhakar Lad
  • Hi Prabhakar.

    Thank you for your response. I have already added the dhcpcd package to my system and it is working as expected. There is still one issue I am facing with it.

    If I configure a static IP through wpa_supplicant and ifconfig would show me correct configured IP. Now, if I switch back to connect to a DHCP AP, IP would get assigned and I can ping to the network with the dynamic IP, but in this case the command "ifconfig" still shows the old static IP. If I run "ip a" and "ip r" commands, I can see the new dynamic IP in the list and I can also see the route being added for the dynamic network.

    Here's the output:

    1. Connected with Static IP to an AP first:

    root@raymond-gdm:~# ifconfig

    wlan0 Link encap:Ethernet HWaddr a8:1b:6a:8d:73:1c
    inet addr:192.168.180.61 Bcast:192.168.180.127 Mask:255.255.255.128
    inet6 addr: fe80::aa1b:6aff:fe8d:731c/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:153 errors:0 dropped:0 overruns:0 frame:0
    TX packets:336 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:19805 (19.3 KiB) TX bytes:52681 (51.4 KiB)

    root@raymond-gdm:~# ip a

    5: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether a8:1b:6a:8d:73:1c brd ff:ff:ff:ff:ff:ff
    inet 192.168.180.61/25 brd 192.168.180.127 scope global wlan0
    valid_lft forever preferred_lft forever

    2. Connectd with DHCP Client to an AP:

    root@raymond-gdm:~# ifconfig

    wlan0 Link encap:Ethernet HWaddr a8:1b:6a:8d:73:1c
    inet addr:192.168.180.61 Bcast:192.168.180.127 Mask:255.255.255.128
    inet6 addr: fe80::aa1b:6aff:fe8d:731c/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:78 errors:0 dropped:0 overruns:0 frame:0
    TX packets:168 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:10351 (10.1 KiB) TX bytes:24341 (23.7 KiB)

    root@raymond-gdm:~# ip a

    5: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether a8:1b:6a:8d:73:1c brd ff:ff:ff:ff:ff:ff
    inet 192.168.180.61/25 brd 192.168.180.127 scope global wlan0
    valid_lft forever preferred_lft forever
    inet 192.168.196.22/23 brd 192.168.197.255 scope global wlan0
    valid_lft forever preferred_lft forever
    inet6 fe80::aa1b:6aff:fe8d:731c/64 scope link
    valid_lft forever preferred_lft forever

    root@raymond-gdm:~# ip r


    default via 192.168.196.1 dev wlan0 src 192.168.196.22 metric 305
    192.168.180.0/25 dev wlan0 proto kernel scope link src 192.168.180.61
    192.168.196.0/23 dev wlan0 proto kernel scope link src 192.168.196.22 metric 305

    ___________________________________________________________________________________

    As seen, when connected with DHCP client, ifconfig still shows 192.168.180.61 instead of 192.168.196.22 (Which got assigned from DHCP server). 'ip a' shows the new IP in the list. 'ip r' shows the default route as it should be for the dynamic IP.

    Can you share what is the reason 'ifconfig' is not being updated to the DHCP based IP? This is not the case when I only connect to various DHCP based APs, it is only the case once I assign the static IP based configuration. As we show the current IP address in the GUI based application, I need this to be fixed to show the current IP configured to the network.

    I would really appreciate your help.

    Thanks,

    Divyeshkumar

  • Prabhakar or Shulev,

    Can you update please?

    Thanks,

    Divyeshkumar