I am trying to understand how NAT and NAT tables work but cant seem to find answers online. I have a few questions regarding NAT. Assume TCP connection made.
Assume router has WAN 184.108.40.206
1) Lets say a device with IP 192.168.1.1 wants to connect to a server with IP 220.127.116.11. The device first encapsulates the data in a IP datagram with source IP as 192.168.1.1 and dest IP as 18.104.22.168 ?
2) After which the datagram is sent to the router where NAT happens. Assuming this is the first packet being sent in the private network, the NAT table is initially empty ?
3) Now there is a entry in the table which maps 192.168.1.1:1234 to 22.214.171.124:2345. ?
192.168.1.1:1234 -> 126.96.36.199:2345
The IP datagram is repackaged with the corresponding router address (188.8.131.52) and port number 2345 before being sent out. Is there a separate TCP connection from the router to the server ? Or is the entry just a virtual port number assigned ?
4) The data comes back from the server 184.108.40.206 with dst IP 220.127.116.11 and dest port 2345. The router does a table look up and finds that 18.104.22.168:2345 is mapped to 192.168.1.1:1234. So it repackages the IP datagram with src address 22.214.171.124:80 and dst address 192.168.1.1:1234
I am not sure if the steps I highlighted are correct.