Linux nat / iptables configuration for this setting

I have an experimental installation of 4 linux (CentOS) machines:

enter image description here

All 4 machines are internally connected using different networks and can ping directly connected interfaces to each other. However, only PC4 has access to the Internet.

I am trying to configure iptable rules that can allow PC1 to access the Internet through PC4, but I do not know how to do this.

I tried adding NAT to the outgoing interface on PC2, PC3 and PC4:

iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

However, this will not work, can you give me an idea of ​​how in this setting I can make access to the PC 10.0.0.1 network?

+5
source share
1 answer

Enable IP Forwarding.

echo 1 > /proc/sys/net/ipv4/ip_forward

/etc/sysctl.conf 0 1

net.ipv4.ip_forward = 1

, sysctl.conf,

sysctl -p /etc/sysctl.conf

Iptables NAT

# /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# /sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
# /sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
+14

All Articles