Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Failure of Port forwarding using NAT server

    Hi, I have a problem in setting up a website on my virtual machine and access it from outside, here are the details:

    I have a HP computer with Centos 6.4, which is behind a Netgear router with an internal static IP of, then I installed RHEL 6.4 as virtual machine on top of this HP, the hypervisor is kvm, and the Virtual Network Interface is NAT, the network of this virtual machine is, this virtual machine was assigned a dynamic IP of I setup a simple webserver on it and it can be seen using I have another Windows 7 hooked to the Netgear router with a static IP of (/24). As of right now, I can ping between the HP and virtual machine (either way), I can also visit the webpage (of the virtual machine) from its host machine (HP) I can ping Dell from virtual machine , but NOT the other way. then I setup this on HP,
    # sysctl -w net.ipv4.ip_forward=1
    # NewServerIP=
    # iptables -t nat -A POSTROUTING -s ${NewServerIP} -j MASQUERADE
    # iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination ${NewServerIP}

    No error ever popped up, according to RH254 (p312), I should be able to ping my virtual machine from the Dell, also I should be able to access its website from Dell, since on my Netgear router, I setup port forwarding (80) to HP host (, then I should be able to access the virtual website from my AT&T smartphone (using 4G, not WiFi connection. This method never worked, I even opened /etc/sysctl.conf to make sure "net.ipv4.ip_forward = 1", then followed by command " sysctl -p", but nothing helps!

    then I used GUI to check firewall setting of this host, in the tab "Port forwarding", it is empty, but if I manually add port forwarding (I use this all the time on my wireless router) here, then everything would work ( virtual webserver works from AT&T smarthone), so I am really buffled why the command based approach won't work?

    ALSO CURIOUS: are you guys familiar with all these commands? I mean there are so many tools in Linux requiring command. I can setup sophisticated stuff with help of Linux handbook, but can't remember all these lol!

    It is long, thanks a lot!

  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    Remembering all the commands takes practice. Once you've been doing it for a couple years, you'll see that there's not really that much to memorize for day to day operations. I recommend keeping some kind of notepad with complicated commands that you use frequently.

    Anyway, you need to set up a route in your Windows 7 machine. By default, each machine generally has one gateway (route) for external networks. You can specify different gateways for different networks. So, on your windows 7 machine, your gateway for network would be 192.168.1.X, where X = IP of your hypervisor.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts