Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dhcp sometimes gives me an APIPA address (169.254.*)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ultraslinky
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jun 2011
Posts: 80
Location: Milan, Italy

PostPosted: Fri Feb 10, 2012 7:37 am    Post subject: dhcp sometimes gives me an APIPA address (169.254.*) Reply with quote

Hello fellow Gentoo users :)

So my wireless works pretty well i must say. However every, let's say, 20th attempt to connect to any wireless (my home, my university, my friend's home etc., definitely not a router problem) i don't get a proper IP address. I'm getting an APIPA address apparently:

Code:
Netbukkolo james # rc-service net.wlan0 start
 * Bringing up interface wlan0
 *   Starting wpa_supplicant on wlan0 ...                                                                              [ ok ]
 *   Starting wpa_cli on wlan0 ...                                                                                     [ ok ]
 *   Backgrounding ... ...
 * WARNING: net.wlan0 has started, but is inactive


I have tried with different programs etc:

Code:
Wicd: Connection failed, unable to get an IP address


This is what ifconfig gives me:

Code:
Netbukkolo james # ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 128  bytes 8064 (7.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 128  bytes 8064 (7.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 169.254.70.226  netmask 255.255.0.0  broadcast 169.254.255.255
        inet6 fe80::221:63ff:fef6:923f  prefixlen 64  scopeid 0x20<link>
        ether 00:21:63:f6:92:3f  txqueuelen 1000  (Ethernet)
        RX packets 18  bytes 2736 (2.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 127  bytes 22226 (21.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


And after killing dhcpcd and running it in a terminal:

Code:
james@Netbukkolo ~ $ sudo dhcpcd wlan0
dhcpcd[2891]: version 5.2.12 starting
dhcpcd[2891]: wlan0: checking for 169.254.85.204
dhcpcd[2891]: wlan0: using IPv4LL address 169.254.85.204
dhcpcd[2891]: forked to background, child pid 2905


I have read this from https://forums.gentoo.org/viewtopic-t-911548.html :

Code:
169.254.* are APIPA addresses which dhcpcd uses when no DHCP server can be reached. Be aware that after dhcpcd gets an APIPA address, it will re-assign it immediately on second launch again, and only change it when a DHCP server replies.

To see whether you have any connection at all, set a static IP address and try to ping hosts on the local network. Also try to launch wpa_supplicant manually and wait for CTRL_EVENT_CONNECTED.


Rebooting gentoo doesn't help, it will keep obtaining that address. I have tried reloading the kernel module but to no avail. However my router's dhcp server is definitely reachable as my cell phone will happily connect to the network, and to solve the problem i have to reboot into Windows (which will connect to the network) and back into Gentoo, then it will give me a proper ip address and internet works.

The question is: How do i stop getting these APIPA addresses? It's just an annoying issue, i know, but still, i'd be interested :)

If it is of any need, my wireless card is:
Code:
02:00.0 Ethernet controller: Atheros Communications Inc. AR242x / AR542x Wireless Network Adapter (PCI-Express) (rev 01)
   Subsystem: Askey Computer Corp. Device 7131
   Flags: bus master, fast devsel, latency 0, IRQ 16
   Memory at f0100000 (64-bit, non-prefetchable) [size=64K]
   Capabilities: [40] Power Management version 2
   Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit-
   Capabilities: [60] Express Legacy Endpoint, MSI 00
   Capabilities: [90] MSI-X: Enable- Count=1 Masked-
   Capabilities: [100] Advanced Error Reporting
   Capabilities: [140] Virtual Channel
   Kernel driver in use: ath5k
   Kernel modules: ath5k


Thanks to everyone in advance!
-James
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15995

PostPosted: Sat Feb 11, 2012 1:08 am    Post subject: Reply with quote

The exact answer depends on your DHCP client. Per man dhcpcd section Local Link configuration, it looks like you want --noipv4ll. This can be passed on the dhcpcd command line via the dhcpcd_eth0 directive in /etc/conf.d/net.
Back to top
View user's profile Send private message
ultraslinky
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jun 2011
Posts: 80
Location: Milan, Italy

PostPosted: Sat Feb 11, 2012 12:49 pm    Post subject: Reply with quote

Thank you Hu :) although i think i need to change the settings for wlan0 and not eth0.

So i could just add ' dhcpcd_wlan0="--noipv4ll" ' in /etc/conf.d/net ? Is that the correct way of writing a directive? Right now my /etc/conf.d/net file is empty, since it defaults to dhcpcd anyway.
Back to top
View user's profile Send private message
ultraslinky
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jun 2011
Posts: 80
Location: Milan, Italy

PostPosted: Sat Feb 11, 2012 12:53 pm    Post subject: Reply with quote

Well i just tried adding that entry and then restarting net.wlan0. I checked dhcpcd's arguments with ps -aux. And it does have the correct command line option :) net.wlan0 complains "WARNING: net.wlan0 has started, but is inactive". It used to do that when i got assigned an APIPA address. However internet works fine and i have a normal 192.* address.

Thanks again Hu!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 46326
Location: 56N 3W

PostPosted: Sat Feb 11, 2012 12:57 pm    Post subject: Reply with quote

ultraslinky,

You get a link local IP if dhcp fails to get a 'real' IP for any reason.

Have you set an overly agressive timeout limit in your /etc/conf.d/net file.
The default is 60 seconds but it only gets to that timeout when something is badly wrong.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
ultraslinky
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jun 2011
Posts: 80
Location: Milan, Italy

PostPosted: Sat Feb 11, 2012 1:03 pm    Post subject: Reply with quote

NeddySeagoon wrote:
ultraslinky,

You get a link local IP if dhcp fails to get a 'real' IP for any reason.

Have you set an overly agressive timeout limit in your /etc/conf.d/net file.
The default is 60 seconds but it only gets to that timeout when something is badly wrong.


Hey NeddySeagoon,

Yeah, i have read the manual about those ipv4ll addresses.
My /etc/conf.d/net file is empty (since it defaults to dhcpcd and i don't need anything else), i just added 'dhcpcd_wlan0="--noipv4ll"'.
However i don't get this "timeout". When i get assigned one of those 169.* addresses, it does so immediately. From the time I invoke dhcpcd to dhcpcd obtaining an 169.* address takes maybe a second, not any more.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum