0

Inside the IPv4 datagram, there are the source and destination IP addresses. The first indicates the IPv4 of the source host, and the second indicates the IPv4 of the destination host.

Are these addresses the corresponding public addresses, or the private addresses?

1
  • 2
    IPv4 has no distinction between private and public addresses. To IPv4, they are just addresses. The private addresses were arbitrarily chosen, and it is just that the ISPs have agreed not to route packets with private addresses on the public Internet. The defined private addresses could change, and IP would never know or care.
    – Ron Maupin
    Commented Apr 10, 2021 at 20:31

2 Answers 2

3

On the Internet, only public addresses can be used. RFC 1918 reserves address ranges that can be used within private networks but not in public. By convention, these addresses are not routed across the Internet.

Inside your private network, both public and your private addresses can be used, in any combination.

  • A packet with private source and public destination is bound to be routed out to the Internet.
  • A packet with public source and private destination is a packet that's come in from the Internet.
  • A packet with private source and private destination is running inside your network, or using tunneling, between private sites.
2

IPv4 itself does not know or care whether IPs are private or public.

Packets traversing the public Internet only use public addresses. So if an internal machine with a private IP wants to communicate with the public internet then NAT will be needed to translate the addresses.

Many networks are configured in an arrangement with the nat on the border between a separate "public network" and "private network". In this arrangement machines on the private side of the border have private IP addresses, so the traffic looks like what Zac mentioned in his answer.

But it's perfectly possible to have a network where devices with private IPs and public IPs coexist and talk to each other via plain routers. If only the devices with public IPs need to talk to the internet then such a network does not need NAT at all. If private IP devices do need to talk to the internet then their traffic will need to be natted, but this does not mean all traffic needs to be. Either the NAT can be on the gateway but with the NAT rules scoped to only apply to particular traffic or policy routing can be used on the main gateway to send traffic originating from private IPs to a seperate NAT box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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