Mark, today want to let a REDHAT7 open iptables NAT forwarding function, find a half day.
A server: 192.168.30.20/24
b Server: 192.168.30.1/24,eth0; 192.168.40.1/24,eth1
C Server: 192.168.40.20/24
Goal: Allow A to ping and ssh to the C machine. This will need to jump through the B server.
Operation Process:
1. Turn on the kernel route forwarding parameter on the B server
Temporary entry into force:
echo "1" >/proc/sys/net/ipv4/ip_forward
For permanent entry, you need to modify the sysctl.conf:
Net.ipv4.ip_forward = 1
Execution Sysctl-p Immediate effect
2, b server turn on iptables NAT forwarding
Iptables-t nat-a postrouting-s 192.168.30.0/24-d 192.168.40.0/24-o eth1-j Masquerade
# Configure the Source Address 30 network segment, Destination address 40 segment of the address translation, from the ETH1 network card out.
Iptables-t nat-a postrouting-s 192.168.40.0/24-d 192.168.30.0/24-o eth0-j Masquerade
#配置源地址40网段, address translation of the destination address 30 network segment, from the Eth0 NIC.
Permanent Save: Iptables-save >/etc/sysconfig/iptables
TIP: note the corresponding network card.
3. Set the route to B server IP on a and C servers
A:route add-net 192.168.40.0 netmask 255.255.255.0 GW 192.168.30.1
C:route add-net 192.168.30.0 netmask 255.255.255.0 GW 192.168.40.1
This article is from the "Danielqu" blog, make sure to keep this source http://qujunorz.blog.51cto.com/6378776/1884459
Easy to use Linux to turn on routing and forwarding functions.