0

I have a web server A and a postfix mail server B. They are all ubuntu server. For some reason B just connect with A and dosen't connect with internet, but A connect with internet. So I think I can set some iptable rules for A and B that will let A be B's router or bridge. I guess I must use DNAT rule but I cannot turn the idea to be ture. Can anybody help me?

1 Answer 1

1
Internet --- (eth0) A (eth1) --- B

You can configure iptables for NAT translation, so packets from B can be routed through A, something like this:

iptables -A FORWARD -i eth1 -o eth0 -s <IP_of_B> -m state --state NEW -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Remember to enable IP forwarding with:

echo 1 > /proc/sys/net/ipv4/ip_forward
2
  • Your rules just include the data form B to A for the server A. What about A to B?
    – Yadun
    Sep 1, 2011 at 9:02
  • The second line will do this. You can also insert -i eth0 -o eth1 for more clearly.
    – quanta
    Sep 1, 2011 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .