title: Port forwarding on NAT using KVM/QEMU
body: <p>I'm using NAT mode for guest networking. I need my machines to be accessible from outside the guest. I've set up iptables to port forward a specific port on host to port 22 on guest, but this does not seem to work.</p>
  
  <p>I added this rules: </p>
  
  <pre><code># Port Forwardings
  -A PREROUTING -i eth0 -p tcp --dport 9867 -j DNAT --to-destination 192.168.122.136:22
  
  # Forward traffic through eth0 - Change to match you out-interface
  -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE 
  </code></pre>
  
  <p>When I <code>ssh 192.168.122.136</code> from host it works perfectly, however when I try <code>ssh 192.168.122.136 -p 9867</code> it shows <code>ssh: connect to host 192.168.122.1 port 9867: Connection refused</code></p>
  
  <p>I've enabled port forwarding on <code>/etc/ufw/sysctl.conf</code></p>
  
  <p>using <code>iptables -t nat -L</code> shows that the rule is set up on iptable</p>
  
  <pre><code>DNAT       tcp  --  anywhere             anywhere             tcp dpt:9867 to:192.168.122.136:22
  </code></pre>