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 126.96.36.199
1) Lets say a device with IP 192.168.1.1 wants to connect to a server with IP 188.8.131.52. The device first encapsulates the data in a IP datagram with source IP as 192.168.1.1 and dest IP as 184.108.40.206 ?
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 220.127.116.11:2345. ?
192.168.1.1:1234 -> 18.104.22.168:2345
The IP datagram is repackaged with the corresponding router address (22.214.171.124) 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 126.96.36.199 with dst IP 188.8.131.52 and dest port 2345. The router does a table look up and finds that 184.108.40.206:2345 is mapped to 192.168.1.1:1234. So it repackages the IP datagram with src address 220.127.116.11:80 and dst address 192.168.1.1:1234
I am not sure if the steps I highlighted are correct.