Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,454

    How can two computers have the same ip address?


    As I write this, my desktop computer and my laptop are both running. The desktop is connected to my router/dhcp server by an ethernet cable, the laptop is connected wirelessly.

    Ifconfig shows that both machines have the same ip address. In the case of the desktop, this has been assigned as a static address; the laptop has presumably been given an address by the router.

    I thought ip addresses had to be unique. How come the router has handed out an address that was already in use on the local network? And how does it know which machine to send stuff to?
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    4,031
    If the IPs of your desktop and laptop are exactly the same, then this is an error.

    My guess is:
    - laptop got its ip from the dhcp range (defined in the dhcp daemon config on your router)
    - desktop was manually assigned an IP, that lies inside the dhcp controlled range. This is the error.

    Afaik, the dhcp daemons dont test if a IP is already active.
    Such a test is not trivial, as there are many edge cases:
    - machines could have firewalls preventing icmp. So a ping test would not be reliable
    - arp doesnt reliably tell you if a IP is assigned to a machine. It just can tell that *right now* a IP corresponds to a MAC.
    - even if there were reliable availability tests: No one is stopping a user to assign a conflicting static IP after the tests.

    Instead dhcp relies on two things:
    - its configuration. Here you can state: Use eg x.x.x.100 to x.x.x.200 for dhcp
    - its leases. The lease files contain information which machine has which mac and ip.
    You must always face the curtain with a bow.

  3. #3
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    4,087
    The IP address has to be unique on its own network. It is possible, but unlikely, that your router presents one network for the wireless and one for the wired. It could be that it's farming out addresses from a DHCP server from separate batches and doing the NAT thing between the two.

    This would, of course, be a huge waste of time inside the router - a pointless exercise. But do-able.

    It's more likely that you have accidentally got one of the devices with a static IP set, but you've not noticed. It would be worth checking. You could also have a buggy DHCP configuration on your router. Or it could be, as Irithori says, just that one has an expired lease and hasn't needed to renew it yet.

    All will continue to work provided you're only using one device at a time. If you're using both together you will encounter problems. You'll confuse the router, so if you get problems perhaps turning off the DHCP and switching everything to statics would resolve the problem for you (you only have two devices, after all - at home I've got five residents' phone/tablet/laptop/desktop/printers/refrigerators, etc. to deal with)
    Linux user #126863 - see http://linuxcounter.net/

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,454
    -->
    Thanks for the quick replies. The problem is that I'm used to having only one computer so, when I did my Linux From Scratch, I used a static ip address as the simplest option. What's more, I used the address that my router had given me in other distros, because I knew that one worked. That's clearly a no-no when you have a second computer which uses dhcp.

    I've just installed dhcpcd on the desktop machine and reconfigured it to use the dhcp service. It came up on reboot with the address 192.168.2.101 so no more duplication. I suppose I need to edit my /etc/hosts file too to take the static address out.

    This is what happens when old biddies of 70 fiddle about with computers and don't really know what they are doing! I've never understood networking. I obviously need to do some reading.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

Posting Permissions

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