The NAT mechanism is implemented inside a routing device that keeps track of the "state" of the network connections. The NAT device may also implement a firewall. The router uses translation tables to map the "hidden" addresses into a single address and then rewrites the outgoing IP packets on exit from the router so that they appear to originate from the router. In the reverse communications path, responses to the outgoing packets are mapped back to the originating IP address using the reverse of the rules (""state"") stored in the translation tables. The outgoing IP packets establish the device translation tables.