4

Think, there are two computers which use two private IP addresses to connect each other. They don't connect to a router so there's no NAT in here. Just peer to peer. But I want to know, can we just use two public IP addresses on these two computers to connect each other, instead of having private IP addresses ?

Thank you !

Zac
  • 99

3 Answers3

9

Yes, you can. There's no inherent hardware limitation preventing you from doing that and all common OSes will assign any IP address you want to interfaces, with the possible exception of multicast addresses, 0.0.0.0, and 255.255.255.255. Some network devices like consumer-grade routers or DSL modems may prevent you from doing this via the firmware.

You can do anything you want on your own LAN.

If you ever expect to connect these systems to an Internet-facing router, though, then you could experience the following issues if you don't stick with private IP ranges:

  • Traffic destined for another host may leak out on to the Internet.
  • You might want to get to the IANA-assigned host on that IP and may not be able to do it if it's an internal host.
  • If you aren't the only one mantaining this network, you could horribly confuse someone who is doing troubleshooting.

ISPs shouldn't let private-IP ranges out onto the public Internet. This convention is why people usually use them when indicated.

LawrenceC
  • 73,957
  • 1
    Keep in mind what you are calling "public" IP address are assigned to entities who pay for those assignements. Generally there is no good reason to use them in this way as there are plenty of private IP addresses as defined by RFC1918. You can find details at Wikipedia if you like: http://en.wikipedia.org/wiki/Private_network – YLearn Apr 07 '13 at 15:24
2

If the two computers are only connected to each other, then you have no need - or ability - to use public IP addesses.

A public IP is assigned to a range or block of addresses. The Internet Assigned Numbers Authority (IANA) controls ownership of these IP ranges and assigns each block to organizations such as Internet Service Providers (ISPs) who in turn allocate individual IP addreses to customers.

Keltari
  • 73,243
  • If you own an IP address block, then you do have the ability to use those public addresses in a private network. (And even if you don't own them – Hamachi "borrowed" an entire 5/8 for their VPN product, while it was officially unallocated.) – u1686_grawity Apr 07 '13 at 13:50
  • 1
    he said the machines were connected only to each other, so he can use any IP address he wants, but they wont be public – Keltari Apr 07 '13 at 13:53
  • yeah I do not want to connect to the internet. Just two computers connected with a Ethernet cable. usually we use 192.168. bla bla. Can I use a 172.x.x.x public address instead? – Zac Apr 07 '13 at 14:32
  • Yeah I tried. I can ping. Used 100.100.100.100 and 100.100.100.200 – Zac Apr 07 '13 at 14:44
  • @Zac: There's actually a private address range 172.16.0.0/12 (as well as 10.0.0.0/8). You are not limited to 192.168/16. – u1686_grawity Apr 07 '13 at 17:50
1

Yes its possible .Public addresses assigned by the ISP is always used in P2P applications such as bittorrent protocol.Here more than two computers connect. Therefore i see no difference in your application

Shenal Silva
  • 1,053
  • 2
  • 15
  • 27