LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   IP address is rarely assigned by DHCP. I managed to get it only once, by fluke (http://www.linuxquestions.org/questions/linux-newbie-8/ip-address-is-rarely-assigned-by-dhcp-i-managed-to-get-it-only-once-by-fluke-744502/)

gregorian 08-02-2009 06:48 AM

IP address is rarely assigned by DHCP. I managed to get it only once, by fluke
 
This is an old thread of mine.
Click if you need the details, but not necessary

I've started this thread because I managed to solve the problem I had only once. It's no longer a question of how to get it work but rather why it doesn't always work.

I use Slackware 12.1. My wireless status light turns on occassionaly during bootup. And on some rare occassions, I actually manage to detect a signal. But without being assigned an IP. That was what my original problem was.

I solved the problem of the light by using:

Code:

sudo ifconfig wlan0 up
This always works.

But there's a catch - dmesg troubles me:
Code:

input: b43-phy0 as /devices/virtual/input/input12
Registered led device: b43-phy0:radio
ADDRCONF(NETDEV_UP): wlan0: link is not ready
b43-phy0: Radio hardware status changed to DISABLED

The status change is always DISABLED whether the light turns on or off. I do not have bluetooth, but the status is always disabled.

sudo iwlist wlan0 scan has never come up with results.

The other command is.
Code:

dhcpcd -d -t 30 wlan0

I nearly fell out of my seat when I saw that it assigned an IP to me. /etc/resolv.conf had the correct nameserver (I know it's correct because I've seen it in Windows). I actually fired up a browser hoping that I'd get the expected username and password screen but I didn't. I couldn't even ping the address in the namserver.

I haven't set the wpa settings in rc.inet1.conf because I don't think I need it. Windows XP lists it as an unsecured wireless network during scanning.

But that can wait. I restarted my computer to see if it would work again - if I could get an IP by executing those two commands. It gave me my MAC address, paused for a while and outputted... nothing. It didn't assign an IP the second time. I tried for about 10 times before I gave up.


Summarising,
  1. I need to know why my status is always disabled in dmesg, even though my light glows. ( I don't have bluetooth)
  2. I need to know why the second command doesn't always work. Remember, it DID work once.
  3. Even though DHCP set my nameserver in /etc/resolv.conf and gave me an IP address, why couldn't I do anything? Couldn't even ping my DHCP server (which also happens to be my DNS server and GATEWAY). The first one's random. But the second one isn't.

Thank you for your help.

EDIT: I managed to get an IP again. Here are the results.

ifconfig -a (Abridged) What's this wmaster0?
Code:

wlan0    Link encap:Ethernet  HWaddr 00:14:a5:22:af:a8 
          inet addr:172.16.254.150  Bcast:172.16.254.150  Mask:255.255.255.255
          inet6 addr: fe80::214:a5ff:fe22:afa8/64 Scope:Link
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10844 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1626364 (1.5 MiB)  TX bytes:4970 (4.8 KiB)

wmaster0  Link encap:UNSPEC  HWaddr 00-14-A5-22-AF-A8-77-6C-00-00-00-00-00-00-00-00 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

cat /etc/resolv.conf
Code:

# Generated by dhcpcd for interface wlan0
nameserver 172.16.1.1

tail /var/log/syslog
Code:

Aug  2 17:35:45 hell dhcpcd[3060]: timed out waiting for a valid DHCP server response
Aug  2 17:36:29 hell dhcpcd[3262]: timed out waiting for a valid DHCP server response
Aug  2 17:41:36 hell dhcpcd[3527]: timed out waiting for a valid DHCP server response
Aug  2 17:41:57 hell dhcpcd[3729]: timed out waiting for a valid DHCP server response
Aug  2 17:42:37 hell dhcpcd[3931]: timed out waiting for a valid DHCP server response
Aug  2 17:43:20 hell dhcpcd[4142]: timed out waiting for a valid DHCP server response
Aug  2 17:46:19 hell dhcpcd[4357]: timed out waiting for a valid DHCP server response
Aug  2 17:47:54 hell dhcpcd[4553]: timed out waiting for a valid DHCP server response
Aug  2 17:48:47 hell dhcpcd[4754]: dhcpConfig: ioctl SIOCDELRT: No such process
Aug  2 17:48:47 hell dhcpcd[4754]: dhcpConfig: ioctl SIOCADDRT: No such process

The timed out responses are all the times it failed. I don't know what the last two lines mean. I know I can increase the timeout (default 30 seconds) but I usually get an IP (if it comes) in 4 seconds. So there's no point.

I get the same output for the following whether my wifi switch is on or off. It's like the IP I obtained means nothing.

ping 172.16.1.1
Code:

connect: Network is unreachable
ping google.com
Code:

ping: unknown host google.com

sundialsvcs 08-03-2009 12:12 AM

The most common reason I have seen for this is that there might be two or more DHCP servers out there, trying to hand out addresses.

Most pieces of consumer-grade hardware (cable modems, routers, and so on) provide DHCP and have it turned-on by default. No explanations are given; no forewarning that you have to turn it off.

edooze 08-03-2009 01:15 AM

Sounds to me like a dodgy signal. i.e it's not strong enough.

For example, I have a signal I can obtain at +50% strength (my neighbour's wireless. Shhh....) and I can't use it or obtain a DHCP address unless I stand by the window (facing north, on one leg, tongue out west) because it's not strong _enough_.

Are there any brick walls or concrete between you and the signal generator? Or, as has been suggested before, any other RF transmitters you are aware of that could be broadcasting at the same frequency? Anybody else around you having this trouble? (Sounds to me like you're in a multi-user environment, which is why I ask)

You mentioned in your previous post your ability to connect with Windows. Have you ever had trouble connecting with windows? Does the status of the light (on/off) affect your ability to connect in windows?

Finally, are you able to connect with a cable at all? This aught to rule out the existence of another DHCP server on said network. Failing that, can you set up a mock network with another router via cable to ensure everything works alright on the computer/build you are using (both DHCP and Static-IP)?

gregorian 08-03-2009 03:37 AM

The fact that I can connect with Windows rules out the possibility of signal obstruction by a physical barrier. The wifi light indicator behaves as expected in Windows i.e. I can't connect when the light is off. I've connected via eth0 on someother connection. I do not have the option of connecting my computer via cable to the router, because I won't be allowed to.

I personally believe that the first step towards solving my problem is to get a signal listing with sudo iwlist wlan0 scan. If you don't mind, could you tell me what's the output of ifconfig wlan0 up followed by dmesg|tail on your system? Even though the light turns on, I get
Code:

input: b43-phy0 as /devices/virtual/input/input12
Registered led device: b43-phy0:radio
ADDRCONF(NETDEV_UP): wlan0: link is not ready

I just tried this and this time, you can see I did not get
b43-phy0: Radio hardware status changed to DISABLED as I mentioned earlier post.

I would really like to know if this is the source of all my problems: ADDRCONF(NETDEV_UP): wlan0: link is not ready

Thank you for your help!

edooze 08-03-2009 05:48 AM

Have you checked /proc/interrupts etc for your card vs those in Windows?
If it is the device that is malfunctioning - and only in linux - I would imagine it only to be the method the software is using to communicate with it.

I just brought my wireless interface down and back up for you, and the last 50 lines of dmesg are all about establishing protocol with my access point. The driver commands are the only others, and they were all developed by Realtek and so are nothing to do with me. When the device is entirely disabled I receive an error with interface flags, so it wouldnt appear that this was your problem either.

Have you investigated if any other processs etc are attempting to access the wlan card? Just an idea. Do you have another wireless network you could try the connection on?

Sorry, I'm not much of an expert when it comes to troubleshooting a wlan device in linux, my background is in networking itself. These are merely the troubleshooting steps I would take were I in the same position.

Hope this helps, let me know if there's some other information I could give you to assist.

gregorian 08-03-2009 10:03 AM

Here's something surprising - iwlist wlan0 scan worked.
(I cannot help but think my computer's pulling my leg)
Code:

wlan0    Scan completed :
          Cell 01 - Address: 00:15:70:D1:67:E4
                    ESSID:"VOLSBB"
                    Mode:Master
                    Channel:11
                    Frequency:2.462 GHz (Channel 11)
                    Quality=45/100  Signal level=-67 dBm  Noise level=-73 dBm
                    Encryption key:off
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
                              11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    Extra:tsf=0000000442cc2807

So I executed

iwconfig wlan0 essid VOLSBB
dhcpd wlan0

This is the result of ifconfig wlan0:
Code:

wlan0    Link encap:Ethernet  HWaddr 00:14:a5:22:af:a8 
          inet addr:172.16.254.150  Bcast:172.16.254.150  Mask:255.255.255.255
          inet6 addr: fe80::214:a5ff:fe22:afa8/64 Scope:Link
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9283 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1270897 (1.2 MiB)  TX bytes:2182 (2.1 KiB)

I actually got an IP address but it seems useless since I cannot even ping my gateway (172.16.1.1)
(I can ping it in Windows). Is there something I need to do even after this point?

I always thought:

ifconfig wlan0 up
iwconfig wlan0 essid VOLSBB
Got VOLSBB from sudo iwlist wlan0 scan
dhcpd wlan0

would be sufficient. Getting an IP address itself is a really lucky moment for me. I hoped that I could atleast connect when I got lucky. See last part of first post for the result of ping. resolv.conf has the correct DNS

mrj 08-03-2009 01:38 PM

Did you read the solution to the problem I was having. I just loaded the most up to date kernel. Apparently, After just loading Lenny, I still had to load the new kernel from synaptic. Read my thread you were reading yesterday (wicd doesn't see my available router signal). mrj.

GrapefruiTgirl 08-03-2009 01:57 PM

I'd like to see the data the OP gave in post#1, except from the Windows OS while that's got a valid working connection.

Reason: Your IP and broadcast address from ifconfig look funny to me; also, you aren't on the same subnet as the DHCP server from the looks of things.

From windows, can you give us the output of 'ipconfig /all' (I hope I remembered that syntax-- it's been a long time) while the win machine is connected and working?

Further to this (but not yet) I'd look into the DHCP configuration, but since you DID say/imply already that everything is fine using Win, so let's assume for now that the DHCP server is set up right.

gregorian 08-03-2009 02:03 PM

Thanks mrj, but as you can see iwlist scan magically works (for now). My problems with wifi seem random. Judging from what you said, I think you could have acheived the same effect by loading an earlier version your wireless driver. I remember Broadcom had different downloads for different kernels.

grapefruitgirl,It runs perfectly in windows.
Result of ipconfig /all in Windows
Code:

Ethernet adapter Wireless Network Connection:
        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : Broadcom 802.11b/g WLAN
        Physical Address. . . . . . . . . : 00-14-A5-22-AF-A8
        Dhcp Enabled. . . . . . . . . . . : Yes
        Autoconfiguration Enabled . . . . : Yes
        IP Address. . . . . . . . . . . . : 172.16.254.150
        Subnet Mask . . . . . . . . . . . : 255.255.255.255
        Default Gateway . . . . . . . . . : 172.16.1.1
        DHCP Server . . . . . . . . . . . : 172.16.1.1
        DNS Servers . . . . . . . . . . . : 172.16.1.1
        Lease Obtained. . . . . . . . . . : Tuesday, August 04, 2009 12:21:24 AM
        Lease Expires . . . . . . . . . . : Wednesday, August 05, 2009 12:21:24 AM

My original question, Is there more to establishing a connection than
ifconfig wlan0 up
iwconfig wlan0 essid VOLSBB
Got VOLSBB from sudo iwlist wlan0 scan
dhcpd wlan0

P.S. How did you determine I was not on the same subnet as the DHCP server? Doesn't the fact we both have 172.16 as the prefix to our IP imply we are on the same network?

GrapefruiTgirl 08-03-2009 02:11 PM

Interesting...... OK, something from my way-back machine: Do you have a file /etc/nsswitch.conf on your linux machine? If so, can you post that file's contents please?

I can't remember *exactly* what it was, but when I first started with Linux, I was getting DHCP for my linux machine from the WInXP machine my roommate has (currently I provide that info to her instead) and for the life of me I could not get to the internet. Eventually the solution was editing my nsswitch.conf file and adding something to it.

Again, I can't remember what it was, but maybe I or someone else will be able to see a problem with that, if there is one.

Thanks :scratch:

gregorian 08-03-2009 09:35 PM

Code:

#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
#      nisplus or nis+        Use NIS+ (NIS version 3)
#      nis or yp              Use NIS (NIS version 2), also called YP
#      dns                    Use DNS (Domain Name Service)
#      files                  Use the local files
#      [NOTFOUND=return]      Stop searching if not found so far
#

# passwd:        files nis
# shadow:        files nis
# group:          files nis

passwd:        compat
group:          compat

hosts:          files dns
networks:      files

services:      files
protocols:      files
rpc:            files
ethers:        files
netmasks:      files
netgroup:      files
bootparams:    files

automount:      files
aliases:        files


GrapefruiTgirl 08-03-2009 09:49 PM

Well, no guarantees at all, but for the record, here's my Slackware 11 nsswitch.conf file as it has been since I got the net working that time as I referred to above. It doesn't look that different from yours, but who knows? Maybe it's worth a try. If not, I'm out of ideas for now, but I hope someone else has some more :)

Sasha

Code:


passwd:    files nisplus nis
shadow:    files nisplus nis
group:      files nisplus nis

hosts:      files nisplus nis dns

services:  nisplus [NOTFOUND=return] files
networks:  nisplus [NOTFOUND=return] files
protocols:  nisplus [NOTFOUND=return] files
rpc:        nisplus [NOTFOUND=return] files
ethers:    nisplus [NOTFOUND=return] files
netmasks:  nisplus [NOTFOUND=return] files   
bootparams: nisplus [NOTFOUND=return] files

netgroup:  nisplus

publickey:  nisplus

automount:  files nisplus
aliases:    files nisplus


gregorian 08-03-2009 10:49 PM

I tried using your file but it didn't work. I restarted my system when I changed the file. When I make changes to the file, is it possible to restart some particular program or do I need to reboot the system everytime I change the file?

Thank you for all the help you've provided so far. Any idea why I have an IP but can't ping my own gateway, dns or dhcp server (all of them run on 172.16.1.1). If pinging 172.16.1.1 gives me network unreachable, what network am I on? How can I have an IP and not be connected at the sane time?

From my first post:
Quote:

I get the same output for the following whether my wifi switch is on or off. It's like the IP I obtained means nothing.

ping 172.16.1.1
Code:

connect: Network is unreachable
ping google.com
Code:

ping: unknown host google.com


gregorian 08-04-2009 01:58 AM

I have connected to the net using an INSANE method I made on my own and is semi logical.

I couldn't connect to the internet using 172.16.1.1, so I added myself as the default gateway. Then I could ping 172.16.1.1 (for the first time). So I added 172.16.1.1 as the default gateway and now I'm here with two default gateways.

route
Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
172.16.254.150  *              255.255.255.255 UH    0      0        0 wlan0
loopback        *              255.0.0.0      U    0      0        0 lo
default        phc.prontonetwo 0.0.0.0        UG    0      0        0 wlan0
default        172.16.254.150  0.0.0.0        UG    0      0        0 wlan0

Now as you can see this is some fluke ad-hoc method I made and I'm not sure if it will work again. The most important point is that I have isolated the problem to the routing tables. I need to learn how to configure the routing tables automatically and correctly. There are two default gateways! routed seems like a useless program that does nothing.

My method of connection is now:
sudo ifconfig wlan0 up
sudo iwlist wlan0 scan
sudo iwconfig wlan0 essid MY_ESSID
dhcpd wlan0
route add default gw MYIPADDRESS
route add default gw MYGATEWAY

Everything works at this point. Please give me a proper way for doing the last two steps. I've never seen it being done anywhere out of the several pages I browsed so I know it's not a standard way of connecting to the net. Adding myself was a casual thought that passed through my mind since I could only ping myself. Can you tell me what I did and why it works? I know routing is used to specify the path a packet must follow. That's all I used to get my connection working.

EDIT: I wrote a script to automate the tasks. I have no experience in shell programming so please let me know if there's something wrong. It works as far as I can see but I'm not sure
Code:

#!/bin/bash

if [ "$1" == "on" ]; then
        echo "Turning on wifi device"
        /sbin/ifconfig wlan0 up
        sleep 2
        echo "Connecting to network"
        /sbin/iwconfig wlan0 essid VOLSBB
        sleep 2
        echo "Obtaining the address"
        /sbin/dhcpcd wlan0
       
        #Obtain IP and store it

        /sbin/ifconfig wlan0 #Display configuration

        IP=`/sbin/ifconfig wlan0|grep "inet addr"|cut -f2 -d:|cut -f1 -dB`
        if [ -n "$IP" ]; then
                /sbin/route add default gw $IP
                /sbin/route add default gw 172.16.1.1
                /sbin/route
        fi
else
        /sbin/ifconfig wlan0 down
        killall dhcpcd
fi


GrapefruiTgirl 08-04-2009 08:54 AM

Hi,

OK, I too run my own DHCP/DNS machine, which is my gateway for our LAN at home. I had to make a weird little script which runs on my DHCP machine after it connects (dialup, dynamic IP) to the internet, so that ITS routing table is correct. After the script runs, our LAN works great; without the script, we get no internet connectivity. So if we get to that point, I'll post my script if it looks like it may help you. Also, if needed, I'll post my DHCP configuration file.

RE: Post #14 above

I know it's many hours after you posted that, AND you have already posted what I'm about to ask for, but while you have it working like you did in post#14, please post:
  • `route -n` from both the DHCP machine, AND the wireless machine.
  • `ifconfig wlan0` on the wireless machine (or of `iwconfig wlan0` if that's what would be used on the wireless)
  • Which & what versions of DHCP and DHCPCD are running on the DHCP Server and the wireless machine.

I'm working toward a couple possibilities here:
  • Windows does some bizarre magic that makes it work, even though technically it should not work.
  • The DHCP server is not providing enough info to the Linux wireless system for it to properly config itself.
  • Routing issues on the DHCP machine are (??) the root of the problem.
  • If you can make it work properly, in a consistent manner WITHOUT USING DHCP, it would lead us in a good direction from here.

To close: similarly to what someone mentioned above, I'm no networking expert either, but have had my share of fiddling & troubleshooting here on my LAN,so no guarantees! I do like troubleshooting though :)

Sasha


All times are GMT -5. The time now is 05:06 AM.