I'm new to NAT and iptables, I have my physical server running CentOS 6 with KVM installed, 2 more linux box is started as VM - VM2 and VM3, and their ip is and accordingly. Since I have one real IP only, NAT is used for port forwarding external request to VM's application, e.g. port 30022 to VM3's ssh (port 22). After setup everything work fine, its running for a month already, but then after I done a RAM upgrade and server reboot, NAT/port forward is not working again.

More information:

  • Iptables running at host OS but NOT at guest OSs.
  • Host OS iptables has configure NAT as follow:
target     prot opt source               destination
DNAT       tcp  --  anywhere             anywhere            tcp dpt:30022 to:
DNAT       tcp  --  anywhere             anywhere            tcp dpt:20022 to:
  • Result of command iptables -t nat -L -v -n:
pkts bytes target     prot opt in     out     source               destination
6   304 LOG        tcp  --  br0    *             tcp dpt:30022 LOG flags 0 level 4 prefix ROUTE APP3
6   304 DNAT       tcp  --  br0    *             tcp dpt:30022 to:
3   152 DNAT       tcp  --  br0    *             tcp dpt:20022 to:
  • That means package is handled by the NAT rule while I try to telnet 30022 from my local PC (separate network)

Have been struggled for few days..any help?

  • Did you run the iptables commands manually or have them saved in a text file? Have you defined any static routes? – Khaled Nov 22 '11 at 8:24

You should check that IP forwarding is enabled on your host using cat /proc/sys/net/ipv4/ip_forward. This command should print 1. If it's not enabled, you should enable it using echo 1 > /proc/sys/net/ipv4/ip_forward.

  • Thanks for your reply! But then I'm afraid its already enabled as the command print 1. – Juchu Nov 22 '11 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.