0

I'm working on an embedded system that will feature a ethernet connection to a PC host. The product contains a DHCP server so the PC can automatically get an IP assigned. In order to not interfere with the host's functions, the 2 IP adresses we assign for that connection (which will always be point-to-point) shouldn't collide with any local networks the PC Host is connected to.

Is there a way to get a range that's guaranteed to be unused? Should I maybe use addresses in 169.254.0.0/16?

Thanks!

EDIT: Some mistakes on my part caused misunderstading. I don't need it to be free as in free beer, what I want is for an user to connect the device to his computer and get a connection automatically set up. If I choose 192.168.43.0/30 for the connection, it might actually interfere with the user if he's using that exact range. That's the problem I'm trying to avoid.

Thank you all for commenting so far!

8
  • "Is there a way to get a range that's guaranteed to be unused?" Unused where? In every possible LAN configuration your solution may end up in? If so, then I'd say No, since you have no control over the LANs and the owners can pick whatever IP range they'd like. Jan 14 '15 at 17:46
  • @Ƭᴇcʜιᴇ007 of course, but (imagining for a second) there may exist a protocol for setting a point to point connection such that both hosts can agree on which ranges not to use.
    – Guido
    Jan 14 '15 at 19:35
  • @Ramhound "free" was a poor choice :) I edited the question to make it clearer. Thanks!
    – Guido
    Jan 14 '15 at 19:35
  • 1
    @Guido - There is a standard. Its RFC1918
    – Ramhound
    Jan 14 '15 at 19:48
1

You can use any of the "internal use" IP address ranges that you are not already using. The easiest is going for a range like 192.168.x.y/24, picking 0<=x<255 as one that you have not used already and y to identify every host you need to. With this, you can support up to 253 hosts.

AFAIK, the IP address you are suggesting is not an "internal use" IP address.

BTW, if this network is totally isolated and has no Internet access, you can any IP range you like.

5
  • The thing is, I need the device to decide the network, and I can't tell which networks the PC host is already on (or can I?). Thanks!
    – Guido
    Jan 14 '15 at 19:33
  • @Guido The IP range is decided in the DHCP server, which you said is on the device. Can you configure it? Typically, (e.g. most wireless routers) the device comes with a default IP and range (e.g. 192.168.1.1 and range 192.168.1.0/24), and then you can go and setup your own custom range in the first setup process.
    – Mahdi
    Jan 14 '15 at 19:42
  • 1
    It is not the case that the IP range is necessarily decided by the DHCP server. It's quite possible just to assign static IP addresses to all devices and do without a DHCP server entirely. Jan 15 '15 at 14:38
  • @Chris The OP particularly mentioned there is DHCP server in the device and I said "typically".
    – Mahdi
    Jan 15 '15 at 15:22
  • The OP said it will always be point-to-point, so for most NICs, that means you need to use a 169.254.0.0/16 address.
    – gogators
    Jan 15 '15 at 20:43
0

Is there a way to get a range that is guaranteed to be unused?

Yes. Any from the RFC1918 IPs. These should never appear on the Internet.

Obvious downside: You can only use them locally.

Never appearing on the Internet does not mean that they are not yet in use on your local network? E.g. many a company does not own suffiecient IP numbers to use them for all their devices and those often call back to a dirty hack called NAT. Usually with IPs from that same rangee. So ask before you use them, or gamble and choose something rare (e.g. 172.16.65.14 and 172.16.65.15, which are from the 1918 range).

An alternative is to use IP v6.

4
  • 2
    I'm not sure this is valid. The problem isn't ensuring the IP address isn't used elsewhere on the Internet, it's ensuring the IP address isn't already used by the host, isn't it? For example, if the host is using 172.16.65.14, OP wouldn't want the embedded system to also claim this. Jan 14 '15 at 18:09
  • Hi, @ChrisInEdmonton is right, that's what I meant!
    – Guido
    Jan 14 '15 at 19:33
  • If you have no control over the local PCs then you can never guarantee not to run into a conflict. However you can avoid it as much as possible by limiting the scope. Using 1918 IPs will avoid all possible used IP addresses on the Internet (assuming that your computer is connected to the Internet). If it is not then you no no idea at all which IP will already been set.
    – Hennes
    Jan 14 '15 at 19:47
  • Using a private address space doesn't guarantee that the address isn't being used which is what the OP asked about.
    – gogators
    Jan 15 '15 at 22:12
0

You can't guarantee that an IP is not being used. However, dhcp clients that conform to the standard behavior will reply with DHCPDECLINE if the address is already in use locally. This applies whether it was assigned manually or via another DHCP server. From rfc2131:

DHCPDECLINE - Client to server indicating network address is already in use.

Additionally, you'll want to use a 169.254.0.0/16 address with a netmask of 255.255.255.252 since it's a point-to-point connection. The DHCPDECLINE says nothing about whether there is another host on the network at the offered IP address, but if you use a 169.254.0.0 (e.g. 169.254.1.2) address with a mask of 255.255.255.252, you can be sure that there will be no conflicts since only 2 hosts can be on that ptp network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.