As a result of the project's needs, the network environment implemented by virtual machines, one of which serves as the bridge, all other machines are transitioned through the bridge, so it is implemented using the linux Iptablesnat function. The network topology is as follows: for bridge, it has a public IP address, an intranet IP address, and other machines only have an intranet IP address.
As a result of the project's needs, the network environment implemented by virtual machines, one of which serves as the bridge, all other machines are transitioned through the bridge, so the linux Iptables nat function is used.
The network topology is as follows:
For bridge, it has a public IP address, an intranet IP address, and other machines only have an intranet IP address, and the bridge intranet IP address is used as the gateway.
To ensure the determination of the network address, first use dhcp to obtain the public IP address, and then use static settings. for how to set the static IP address, refer to Centos (1) to set the static IP address as follows:
Currently, the following information is available for bridge posts:
Set other intranet machines as follows:
Test the network connectivity, and access the external IP address from the inside can be connected.
Set on bridgeIptablesAs follows:
Test whether iptables works. use iptables-t nat-L. We found that port 22 of 192.168.110.10 exists.
This step is the most critical. at that time, I did not set this step, which caused access to port 1022 of 10.64.70.64 from the outside to fail.
Set net. ipv4.ip _ forwarding in/etc/sysctrl. conf,
So far, iptables has ended to implement the above network architecture. in this process, there is no way to use a lot of content found on the network, this document serves as the basis for future queries.
I also hope it will be useful to others.
Add on 8/12
After we have configured nat, we can test their connectivity, but if it doesn't work, how can we debug it.
First, add the following content to/etc/sysconfig/iptables.
-A prerouting-I eth0-p tcp-j LOG -- log-level warning -- log-prefix "*** nat-statu ***"
Restart iptables
Service iptables restart
In this case, we use the warning method to print every incoming tcp information.
Second, set syslog
Vim/etc/syslog. conf
#2 Add the following content
Kern. warning/var/log/iptables. log
Restart syslog
You can view the connection information in/var/log/iptables. log.
In this way, you can implement simple debug.