Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 192.168.122.2 and 192.168.122.3 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:192.168.122.3:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:20022 to:192.168.122.2:22(22)
  • Result of command iptables -t nat -L -v -n:
pkts bytes target     prot opt in     out     source               destination
6   304 LOG        tcp  --  br0    *       0.0.0.0/0            0.0.0.0/0           tcp dpt:30022 LOG flags 0 level 4 prefix ROUTE APP3
6   304 DNAT       tcp  --  br0    *       0.0.0.0/0            0.0.0.0/0           tcp dpt:30022 to:192.168.122.3:22
3   152 DNAT       tcp  --  br0    *       0.0.0.0/0            0.0.0.0/0           tcp dpt:20022 to:192.168.122.2:22
  • 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?

share|improve this question
    
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

1 Answer 1

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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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