Nat:network address Transfer, a network address translation, converts the addresses of hosts on a network in which one of the NICs are connected to the address of a host in another network. Routing can also be implemented to convert a message in one network to another network
The application scenario is:
SNAT: Source address translation, conversion of IP messages in the source IP address
Dnat: Target address translation, conversion of IP address
The following describes how to implement message forwarding between hosts through routing
Example Analysis:
Prepare three virtual machines, one host is assumed to be C host (routing), there are two network cards, the first network card set to bridge, the second block set to Host-only
One host is assumed to be a host, the network card is set to bridge, the other host assumes B host, and the NIC is set to Host-only
C Host two network card IP is: 172.16.50.10;192.168.10.1
B Host IP: 172.16.50.5 Gateway: 172.16.50.10
A host IP is: 192.168.10.2 Gateway: 192.168.10.1
1, first on the B host can ping their own gateway 192.168.10.1
2, open the C host data forwarding function (modify the configuration file, can be permanently effective)
[Root@localhost ~]# vim/etc/sysctl.conf
Net.ipv4.ip_forward = 1
[Root@localhost ~]# sysctl-p Direct entry into force