Thread: DHCP & routing table

  1. #1
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902

    DHCP & routing table

    I am trying to configure my system (laptop, linux) to connect to a wireless point here at my school. I'm almost certain I've got my configuration correction, but I'd like a sanity check.

    The wireless point is an 802.1x using EAP-MSCHAPv2. This is not a problem - I can associate with the AP and authentication succeeds. It's DHCP that's the issue. My client (dhcpcd) successfully goes through all the steps: discover, offer, request, ack - it reports all and I can capture all of these steps in a Wireshark capture. It fails on setting up the system at times, with the error of "add_route: No such process"

    Sometimes it works, sometimes it doesn't, depending where I am on the campus. I feel that I'm getting a bogus DHCP response from the router. Now, routing tables are not my strong point, so feel free to correct me. When it fails, I generally see something like:

    Subnet mask = 255.255.253.0
    IP = some IP address
    gateway = some other IP address

    Now, that subnet mask just looks weird - is it valid? Further, if I do:
    Code:
    my IP (binary AND) subnet_mask;
    gateway's IP (binary AND) subnet_mask;
    I end up with two different answers. To me, this says that the gateway and me are on different networks. My understanding is that the gateway is my sort of "portal" to other networks. If something is on another network, I need to go through the gateway. If the gateway is on another network... well, that seems very chicken-and-egg to me.

    I found somewhere else that said in this case where the IP & gateway differ like that, that the DHCP response should contain additional info for a route to the gateway. I'm almost certain through my wireshark captures that the DHCP server is not sending anything extra.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Any subnet mask is valid, just for sanity there are certain conventions. But yes that one is valid. Theres no rule saying the subnet has to be divided by octets. That one is a bit weird though, most people would have used 254 or 252 unless the company just got unlucky enough to have two class C IP's that were not consecutive, although i guess another way to look at it is they got lucky enough to get 2 that are subnettable at all.

    The way subnets work is,
    A = your gateways subnet
    B = your gateways internal IP
    C = destination IP of the packet

    if A & B == A & C the packet is local, otherwise it is gets sent up to the next router/switch/hub

    or more specifically the way its actually done in the routers
    Code:
    if((A & B) ^ (A & C)){
       localpacket();
       } else forwardpacket();
    Last edited by abachler; 09-02-2009 at 08:43 AM.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    253 (11111101b) sounds really strange for subnet mask.

    What IP address and gateway address do you get? (it's okay to post them, since they are not external IPs, assuming it's not the ISP that is answering your DHCP request!)

    What IP do you get when it works?

    Also, just to point out the obvious... have you tried contacting the network admin?

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    I get an external IP, actually. In this instance, my school is my ISP. (It's a college.) I'll randomize a few numbers for an example:

    I'll get the following, for example:
    128.100.203.123 = my IP
    128.100.206.1 = gateway
    255.255.253.0 = subnet mask

    My understanding was that if (some_ip & netmask) and (gateways_ip & netmask) differed, then some_ip was on a different network, and the packet would be routed to the gateway to get it there. Now, following that logic, my network for the IP address I'm getting is not the same as the gateway's network. This raises to me, how do you route a packet to the gateway, if it's not in your network? I believe this is why route is choking in the dhcpcd's configure process.

    The odd thing is that Window's succeeds in these places, but it seems to get 2 IPs - one from the DHCP server that's giving me issues, and one from a more common 192.168.1.1 server. I might have to poke more. There seem to be entries for both in the routing table in windows - which is _huge_ compared to the usual 3 entries in Linux.

    I was thinking of contacting the network admin -- that was mostly the point of the post. I wanted to make sure I'm on the right track before I contact them.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    It's possible that there are 2 DHCP servers on the network, and they are competing to give you an IP (race condition). This is possible, for example, when you have a hub that both the ISP modem and the NAT is connected to. It will work about 50% of the time, when the NAT wins. I doubt a college network would be set up like that, though... People usually do this because they don't want to get a second network card for the NAT (to make it modem->NAT->hub).

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    And yet everything works?

    What does your routing table look like in full? If there was a direct route to the gateway on the main network interface, everything could still work.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    [off-topic]
    Has anybody know a good free online (or downloadable) tutorial about these stuffs?
    I searched a little, and I have a book named "Networking in Vista". But they arenot whatI need. I thought maybe you know a better one.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  2. How i can modify routing table and coding on MAC layer?
    By comsci42 in forum Networking/Device Communication
    Replies: 0
    Last Post: 04-09-2006, 06:47 PM
  3. extra word printing
    By kashifk in forum C++ Programming
    Replies: 2
    Last Post: 10-25-2003, 04:03 PM
  4. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 07:18 AM
  5. help with operator <
    By kashifk in forum C++ Programming
    Replies: 1
    Last Post: 10-21-2003, 03:49 PM