0

I am unable to connect to WEP wifi on Linux (Mint): I get no DHCP offer.

My bash script (that I launch as root) does the following:

pkill dhclient
pkill wpa_supplicant #just in case
ip link set dev wlan0 down
ip addr flush dev wlan0
iwconfig wlan0 essid "MyWifi"
iwconfig wlan0 enc off
ip link set dev wlan0 up
dhclient -v wlan0

When I launch it, I get no DHCP offer:

Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/e8:4e:06:24:b2:9e
Sending on   LPF/wlan0/e8:4e:06:24:b2:9e
Sending on   Socket/fallback
DHCPREQUEST of 192.168.100.101 on wlan0 to 255.255.255.255 port 67 (xid=0x19efd6f2)
DHCPREQUEST of 192.168.100.101 on wlan0 to 255.255.255.255 port 67 (xid=0x19efd6f2)
DHCPREQUEST of 192.168.100.101 on wlan0 to 255.255.255.255 port 67 (xid=0x19efd6f2)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3 (xid=0x17d23b2f)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3 (xid=0x17d23b2f)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5 (xid=0x17d23b2f)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11 (xid=0x17d23b2f)
...

Important:

  • I do not have NetworkManager (not running and removed - I saw that was a common issue) and I prefer to use command line.
  • When I scan for my wifi, I see it no problem:

    sudo iwlist wlan0 scan
      wlan0     Scan completed :
       Cell 01 - Address: 20:C9
       [..]
       Cell 02 - Address: 02:26:C6:2F:46:7E
                Channel:9
                Frequency:2.452 GHz (Channel 9)
                Quality=54/70  Signal level=-56 dBm  
                Encryption key:off
                ESSID:"MyWifi"
                Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 48 Mb/s
                          54 Mb/s; 6 Mb/s; 9 Mb/s
                Bit Rates:12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                Mode:Ad-Hoc
                Extra:tsf=0000000001ed4e21
                Extra: Last beacon: 32ms ago
                IE: Unknown: 000B6950686F6E65204D795769
                IE: Unknown: 010882848B96606C0C12
                IE: Unknown: 030109
                IE: Unknown: 06020000
                IE: Unknown: 2A0100
                IE: Unknown: 320418243048
    
  • I know that wifi works as I have other equipments connect to it

  • I know my wifi dongle works too as I manage to connect to other wifi (WPA).

user1381
  • 506
  • 1
  • 5
  • 19

1 Answers1

1

Ok I found the solution. I was using mode 'managed' by default. But in the iwlist scan, it says 'ad-hoc':

 Mode:Ad-Hoc

So, the correct script to connect to my Wifi is:

 #!/bin/bash
 pkill dhclient
 pkill wpa_supplicant #just in case
 ip link set dev wlan0 down
 ip addr flush dev wlan0
 iwconfig wlan0 essid "MyWifi"
 iwconfig wlan0 enc off
 iwconfig wlan0 key off
 iwconfig wlan0 mode Ad-Hoc
 ip link set dev wlan0 up
 dhclient -v wlan0

and that works :)

user1381
  • 506
  • 1
  • 5
  • 19