dhclient does not work on wlan0 with WEP. How do I fix it?

8,119

Check if you see any incoming traffic using tcpdump on wlan0:

tcpdump -i wlan0 -nl

Then install arping and check if your router (or anything) on the other side is responding (via IP or MAC):

sudo arping -i wlan0 IP
sudo arping -i wlan0 MAC

There is a trick on FreeBSD and Mac (which doesn't exist on Linux) to send the broadcast message using arping (or arping2):

sudo arping -i wlan0 ff:ff:ff:ff:ff:ff

This is additional method to check if anything on the other side is responding.

Basically if nothing is responding, check your WEP key, if something is responding, check if you have incoming DHCP packet, if not check your DHCP server (maybe you have some ACL restriction based on MAC addresses).

The other diagnostics commands which you can execute are:

dmesg | tail

to see if there are no any kernel messages (i.e. driver errors, etc).

Check as well if you have a linux tool: iw (man iw).

It could give you same more options and possibilities. See: http://wireless.kernel.org/en/users/Documentation/iw/

Example (To connect to an AP that uses WEP):

iw wlan0 connect foo keys 0:abcde d:1:0011223344).

Once you have answer from the router, you can check if you're connected to the internet.

Check the gateway first, if it's correct:

netstat -nr | head

Should be the first IP address under Gateway column. Make sure it's responding for standard pings (ping IP).

If not, you have some configuration issue on the router.

If yes, then try to ping the nearest DNS by:

ping 4.2.2.1

If you have the response (that means you have external access), you should check your DNS configuration in /etc/resolv.conf (e.g. by adding this line: nameserver 4.2.2.1) or check on the router if it assigned to you the right ones.

Share:
8,119
Salil
Author by

Salil

Updated on September 18, 2022

Comments

  • Salil
    Salil almost 2 years

    I am installing FreeBSD 9.0 on my desktop. My wireless card is Intel-based (wip). bsdinstall correctly sets up my wireless and my wlan0 gets associated with my WEP wireless network and I get DHCP address assigned by the router. However, I cannot connect to the internet. This does not happen if I use my wired connection (fxp0 interface). I get connected by wireless from my Linux laptop. So, it's a configuration issue.

    My /etc/rc.conf:

    hostname="blah.."
    wlans_wpi0="wlan0"
    ifconfig_wlan0="WPA DHCP"
    ..
    

    My /etc/wpa_supplicant.conf:

    ctrl_interface=/var/run/wpa_supplicant
    eapol_version=2
    ap_scan=1
    fast_reauth=1
    
    network={
        ssid="{my ssid}"
        key_mgmt=WPA-PSK
        proto=RSN
        psk="{my passphrase}"
        priority=2
    }
    network={
      priority=5
      key_mgmt=NONE
    }
    

    Everything looks correctly configured, that is, my wireless is associated and I have a DHCP-server (my router-cum-access point) assigned IP address. However, I cannot even ping my router.

    salil-satellite# /etc/rc.d/netif restart wlan0
    Stopping wpa_supplicant.
    Waiting for PIDS: 429.
    Stopping Network: wlan0.
    wlan0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:13:02:68:0e:e2
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid "" channel 11 (2462 MHz 11g)
        country US authmode WPA2/802.11i privacy OFF txpower 0 bmiss 7
        scanvalid 60 protmode CTS
    Starting wpa_supplicant.
    wlan0: no link ....... got link
    DHCPREQUEST on wlan0 to 255.255.255.255 port 67
    DHCPREQUEST on wlan0 to 255.255.255.255 port 67
    ip length 314 disagrees with bytes received 534.
    accepting packet with data after udp payload.
    DHCPACK from 192.168.1.1
    bound to 192.168.1.2 -- renewal in 24701 seconds.
    Starting Network: wlan0.
    wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:13:02:68:0e:e2
        inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
        status: associated
        ssid salquestfl channel 11 (2462 MHz 11g) bssid 00:1b:2f:4a:6a:00
        country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
        AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 0 bmiss 7 scanvalid 60
        protmode CTS roaming MANUAL
    
    salil-satellite# tail /var/log/messages 
    Jul 31 23:44:44 salil-satellite dhclient[3225]: My address (192.168.1.2) was deleted, dhclient exiting
    Jul 31 23:44:44 salil-satellite kernel: wpi0: need multicast update callback
    Jul 31 23:44:44 salil-satellite kernel: wpi0: need multicast update callback
    Jul 31 23:44:44 salil-satellite dhclient: New IP Address (wlan0): 192.168.1.4
    Jul 31 23:44:44 salil-satellite dhclient: New Subnet Mask (wlan0): 255.255.255.0
    Jul 31 23:44:44 salil-satellite dhclient: New Broadcast Address (wlan0): 192.168.1.255
    Jul 31 23:44:44 salil-satellite dhclient[3213]: connection closed
    Jul 31 23:44:44 salil-satellite dhclient[3213]: exiting.
    Jul 31 23:44:44 salil-satellite dhclient: New Routers (wlan0): 192.168.1.1
    Jul 31 23:44:48 salil-satellite init: getty repeating too quickly on port /dev/ttyv8, sleeping 30 secs
    

    One thing that is surpising is my routing tables are just the way before I switched to wlan0 from fxp0. There is no mention of wlan0 interface there.

    salil-satellite# netstat -nr 
    Routing tables
    
    Internet:
    Destination        Gateway            Flags    Refs      Use  Netif Expire
    default            192.168.1.1        UGS         0    57365   fxp0
    127.0.0.1          link#10            UH          0        0    lo0
    192.168.1.0/24     link#9             U           0      684   fxp0
    192.168.1.3        link#9             UHS         0        0    lo0
    192.168.1.4        link#11            UHS         0        0    lo0
    
    salil-satellite# vi /etc/resolv.conf 
    
    # Generated by resolvconf
    nameserver 192.168.1.1
    :q
    
    salil-satellite# ping 192.168.1.1
    PING 192.168.1.1 (192.168.1.1): 56 data bytes
    ping: sendto: Host is down
    ping: sendto: Host is down
    ^C
    --- 192.168.1.1 ping statistics ---
    4 packets transmitted, 0 packets received, 100.0% packet loss
    salil-satellite# ifconfig wlan0
    wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:13:02:68:0e:e2
        inet 192.168.1.4 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
        status: associated
        ssid salquestfl channel 11 (2462 MHz 11g) bssid 00:1b:2f:4a:6a:00
        country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
        AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 0 bmiss 7 scanvalid 60
        protmode CTS roaming MANUAL
    

    However, I can reach my router if I use arping.

    salil-satellite# arping -i wlan0 192.168.1.1
    ARPING 192.168.1.1
    42 bytes from 00:1b:2f:4a:6a:00 (192.168.1.1): index=0 time=1.501 msec
    42 bytes from 00:1b:2f:4a:6a:00 (192.168.1.1): index=1 time=1.509 msec
    42 bytes from 00:1b:2f:4a:6a:00 (192.168.1.1): index=2 time=1.498 msec
    42 bytes from 00:1b:2f:4a:6a:00 (192.168.1.1): index=3 time=1.490 msec
    42 bytes from 00:1b:2f:4a:6a:00 (192.168.1.1): index=4 time=1.600 msec
    ^C
    --- 192.168.1.1 statistics ---
    

    On my router side, I checked which devices it thinks are attached to it and it correctly shows the wireless interface address and its MAC address.

    • Spiff
      Spiff almost 12 years
      Hopefully you didn't really put a 124-bit key as your WEP key. WEP keys are either 40 bits (64 with Initialization Vector) or 104 bits (128 with IV). So your WEP key should either be 5 or 13 ASCII characters, or 10 or 26 hexadecimal digits.
    • Salil
      Salil almost 12 years
      @Spiff, you are right. It's a 40-bit (10 digit hex) key. My key is correct, just to reaffirm.
    • kenorb
      kenorb almost 12 years
      If your router doesn't respond to arping (hardware layer), there is no any connection between the networks. You could have different network, even you could have no IP at all, but device must answer to arping. (P.S. When using arping broadcast, add the interface as well). Check as well cmd: dmesg | tail; if you have any kernel errors. You should focus on making the physical connection, not on DHCP. Try as well cmd: sudo arping -i wlan0 00:1b:2f:4a:6a:00 (your AP). If you can, please test the connection without WEP first, then you'll know that drivers are ok, and the only problem is your WEP.
    • kenorb
      kenorb almost 12 years
      In my opinion there is definitely problem with the WEP key. Try to connect by removing WEP at all (if you can), or change it to different method of authentication. The other think, I don't know if it's related, your AP says wepkey 1:104-bit and you're typing "40-bit hex key".
    • kenorb
      kenorb almost 12 years
      Check as well if you have tool: iw (man iw). It could give you same more options and possibilities. See: wireless.kernel.org/en/users/Documentation/iw (Example: iw wlan0 connect foo keys 0:abcde d:1:0011223344).
    • Salil
      Salil almost 12 years
      @kenorb, many thanks for your suggestions. I think we are close to resolutions. I changed my encryption from WEP to WPA-PSK and I used SYNCDHCP instead of DHCP in my /etc/rc.conf. Now, I get a valid DHCP response and an IP. However, I cannot connect to internet. And you were right about arping. I do get valid response from the router by arping. I was using a wrong ip address for arping. Sorry for that.
    • Salil
      Salil almost 12 years
      I have updated my question, because I do not want to clutter my question with a lot of information.
    • kenorb
      kenorb almost 12 years
      I've updated the answer.
    • Salil
      Salil almost 12 years
      Updated with neststat routing info. One thing that is surpising is my routing tables are just the way before I switched to wlan0 from fxp0. There is no mention of wlan0 interface there.
    • kenorb
      kenorb almost 12 years
      Yes, you have network conflicts between the interfaces. The host is down, because it's going through the wrong interface. You're connecting to router via wlan0 (WiFi), but routing going through fxp0. If you don't want to use one interface, temporary disable it by: ifconfig fxp0 down, the routing should be updated automatically, otherwise you'll lost and never fix it. Make sure that you're using one interface at the time and that your routing and gateway is set to the same interface, then it should work.
    • Salil
      Salil almost 12 years
      yup, the routing tables were the problem. after rebooting, it worked. thank you so much for your help.
    • kenorb
      kenorb almost 12 years
      That's great it worked:)