Find the answer to your Linux question:
Results 1 to 9 of 9
I have 2 machines connected, one with a wire (ethernet) and one wifi. All this while, the eth one has been I think 192.168.1.2 . However yesterday I booted a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Mar 2013
    Posts
    492

    How does a wifi router assign IP addresses?


    I have 2 machines connected, one with a wire (ethernet) and one wifi. All this while, the eth one has been I think 192.168.1.2 . However yesterday I booted a Sabayon live DVD, as I've mentioned in aanother thread, and I noticed I had now become 192.16.8.1.5 !!

    How is the actual DHCP assignment done? Is it DEPENDENT ON DISTRO???!!!!



    Thx.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,934
    DHCP is a server process, it doesn't normally run on your desktop or laptop machine. It is possible that you have a separate DHCP running on your ADSL modem or Firewall and another running on your wireless access point - normally this is a bad idea, and you only want one running to prevent them both issuing the same address to different devices/machines.

    But in your case, that's unlikely to be the issue.

    192.16.8.1.5, the address you're quoting. IPv4 addresses are in 'dotted quad' format, i.e. in the form A.B.C.D, because they consist of four bytes. You have five here. Although it's likely to be a mistake in the output as it looks a lot like 192.168.1.5...

    So... I suggest that your machine is now running on x.x.x.5 when previously it was x.x.x.2. Does the connection still work? Is this causing you a specific problem to do with lack of connectivity?
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux User
    Join Date
    Mar 2013
    Posts
    492
    Eh sorry, that was just a typing mistake. The connection works, but I would obviously not like to keep editing conf files when I'm tinkering around, I'd like to know that each machine is so.and.so . If I have to keep typing ifconfig to see what ip it curently is, I'll go mad

    My wifi thingy is a router cum wifi access point. Iwas talking about the DHCP server running on IT.

  4. $spacer_open
    $spacer_close
  5. #4
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,934
    Ahhh, rite. There are two ways to resolve this.

    The best way is to modify the DHCP server configuration. What you want to do is add a static assignment, forcing the DHCP system to always hand out the same IP address based on the hardware address - also known as the MAC address. You can see this number by typing /sbin/ifconfig at the command line - it's the 6 byte number separated by colons, a bit like 'XX:XX:XX:XX:XX:XX' but with actual hex digits instead of Xs. Making this change means you'll always get the same IP address handed to you by the DHCP server.

    The other way is to use a static IP address configured on your desktop machine, but this can bring some extra problems. The DHCP system doesn't just allocate your IP address, but is also responsible for setting things like DNS server IP addresses, gateway IP address, and internet domain name. Some of these may be allocated your router by your ISP, and passed on. If they don't change and you can read off from your router what they are, then you can add them to your network interface config on your desktop machine. In the interface settings page, turn off it's use of DHCP and set it to static, then fill out the information your connection uses.

    If you go down the static IP route, then it would be best to either turn off the DHCP server on your router, or configure it so that it never hands out the static IP address you've chosen - the last thing you want is someone with a mobile phone or other device connecting to your wifi and being allocated the same IP address that you're using as a static, because then nothing will work properly for either your desktop of the other device.
    Linux user #126863 - see http://linuxcounter.net/

  6. #5
    Linux User
    Join Date
    Mar 2013
    Posts
    492
    Quote Originally Posted by Roxoff View Post
    Ahhh, rite. There are two ways to resolve this.

    The best way is to modify the DHCP server configuration. What you want to do is add a static assignment, forcing the DHCP system to always hand out the same IP address based on the hardware address - also known as the MAC address. You can see this number by typing /sbin/ifconfig at the command line - it's the 6 byte number separated by colons, a bit like 'XX:XX:XX:XX:XX:XX' but with actual hex digits instead of Xs. Making this change means you'll always get the same IP address handed to you by the DHCP server..
    ... and what is that MAC address for a Wifi interface?

    And, how do I actually DO the DHCP configuration? I know how to get Into my router, then what?


    Also, can you explain the DHCP server setting the domain name, I don't really get that....?




    Thanks so much for your help.

  7. #6
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,934
    I found a bit of a lightweight introduction to DHCP here: DHCP: Protocol introduction

    It might help a little. Of course, your router's configuration pages will be laid out in some custom style, so I can't tell you which buttons to click, I can explain a little of the process.

    In short DHCP is a short protocol which allows a device to broadcast a call for configuration to a network when it first connects and before any ethernet/IP configuration is carried out. The broadcast can be answered by any service listening for these DHCP requests (which is why you only want one on your lan).

    In reply, the server will send a block of data back to the source telling it to use a particular IP address and maybe additional information such as domain name (that's internet domain, not a windows domain) and other parameters such as gateway address, netmask, DNS server information, who the YP servers are, and several other snippets of data that are probably not relevant to your network - you're really interested in four things: network IP address, netmask, gateway IP address and DNS server data. You -might- be interested in the local domain, but it's only really important if you have more than one machine on the network and want to browse files on them.

    The DHCP server receives requests identified by hardware address, this is the 6-byte MAC address assigned to your network interface. Every ethernet card and wifi card has one, and the server usually tries to allocate the same IP address if it can to a particular host (but this isn't guaranteed - as you've seen). It does this by having a static set of data for the dns/gateway, etc., and a pool of IP addresses it can draw from. it allocates each one to one host.

    To ensure it doesn't run out of IP addresses, it needs to know when an address isn't in use any more - it does this by a lease time (usually one or two hours) after which a re-request must be made by the computer using the IP address to extend its lease, i.e. it does another DHCP request. If this isn't done the server will consider the IP to be free again and return it to the pool.

    The configuration for the DHCP server will consist of settings for the static data - but some of this will have been gathered by its connection to the internet through your ISP connection, so it's best not to change these. As your DHCP is on your router, then the gateway address will likely be your routers IP address on the lan (a 192.168.x.x address).

    In the configuration, you should be able to define the IP addresses in the pool. You should also have access to 'static assignments'. You can add your hardware address to the static list and give yourself a static IP assignment, achieving the unchanging IP address you desire. Of course, you must also ensure that the address you assign statically in this way is removed from the pool. The address pool is usually defined by a range, so just adjust the start and end address range so it doesn't overlap either the router's IP or your static one. Try and keep the pool as big as you can, but you really shouldn't need more than a hundred or so addresses. Probably 192.168.1.10 to 192.168.1.100 would be safe for your network, that'd mean you're safe to use 192.168.1.2 for your desktop machine, and I guess your router is probably using 192.168.1.1.

    The only thing left to get is the hardware address (the MAC address) of each of your network cards. Your output from a simple /sbin/ifconfig at the command line will provide that information. The block will look a bit like this:

    Code:
    eth0 Link encap:Ethernet HWaddr 00:01:20:40:43:1C
         inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
         UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
         RX packets:1771 errors:0 dropped:0 overruns:0 frame:0
         TX packets:359 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:138184 (134.9 KiB) TX bytes:49108 (47.9 KiB)
         Interrupt:67 Base address:0x2000
    There will be multiple blocks, one for each of your interfaces (including lo, the loopback/internal adaptor). The bit of information you need is the bit after the 'HWaddr' for your wifi card. The names of these interfaces can vary machine to machine, so the one you want will be the one that -isn't- called something like 'lo' or 'ethX'. The value is 6 bytes, expressed as 2-character hex digits separated by colons, as in the example above. You should be able to cut-and-paste the value into the MAC address box of your router's DHCP static assignments box - but I've known some in the past that wanted it without the colons in, so try it with them in place first.
    Linux user #126863 - see http://linuxcounter.net/

  8. #7
    Linux User
    Join Date
    Mar 2013
    Posts
    492
    Oh my God.. thanks so much man! I had figured out most of that stuff myself, but anyway,..... I'm immigrating to Nottingham, England soon if that's where Linux knowhow and people like you are found!

  9. #8
    Linux User
    Join Date
    Mar 2013
    Posts
    492
    By the way, is "router" really the right term for my Wifi box thingy? In that case, what exactly is a "bridge"?

  10. #9
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,934
    What you need is a jargon buster...

    What is a Bridge

    What is a Router

    In practice many of these terms are used interchangeably these days. A bridge spans two networks and lets traffic flow between them. That's also what a gateway does. A router routes network traffic between nodes, and that, of course, is also what a bridge does. And a gateway. And a firewall.

    These terms are used in the IT world and are lifted from real life paradigms, making it possible to have a real stab at understanding them without even looking them up.
    Linux user #126863 - see http://linuxcounter.net/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •