0

I am trying to get KVM working on my Debian server and I am having a slight problem with networking with my guest OS (also Debian). The virtual machine is using the "default" network (without a bridge). The host server gets all of the IPs and to allow the guest to serve content, I add these rules to my iptables:

/sbin/iptables -t nat -I PREROUTING -d xxx.xxx.xxx.134 -j DNAT --to 192.168.122.160
/sbin/iptables -t nat -I POSTROUTING -s 192.168.122.160 -j SNAT --to xxx.xxx.xxx.134
/sbin/iptables -t filter -I FORWARD -d 192.168.122.160 -j ACCEPT
/sbin/iptables -t filter -I FORWARD -s 192.168.122.160 -j ACCEPT

I also have several other virtual machines I want to add and give them internet access without having any public-facing servers, therefore no ports need to be forwarded to these VMs (besides, I don't have enough public IPs to give each server its own IP).

The problem is that if don't add these rules to iptables, I can only access the local network from the VM (however DNS is working fine). If I try to ping anything (e.g. google.com), it resolves the IP, but doesn't receive any response. Is there some other sort of rule I need to add to iptables or anything else I need to do so that the guest can access the internet without forwarding any ports to it?

6
  • Spare yourself a lot of pain and put them on a bridge. Feb 13, 2015 at 5:34
  • I tried that and couldn't even reach the host server... DHCP wasn't working and if I tried static IPs I couldn't access anything.
    – Mike
    Feb 13, 2015 at 5:36
  • Troubleshooting the problem with the bridge might be less of a headache than following another process. If you want to do it for academic purposes that is one thing, but as far as pure functional setup, better to do things right, than to do things clever
    – Gravy
    Feb 13, 2015 at 6:02
  • @gravy I'm trying to set it up with bridging again to see how far I get.
    – Mike
    Feb 13, 2015 at 6:06
  • @Mike Probably a good call. If you run into specific problems with that I'm sure you can find answers here. Best of luck!
    – Gravy
    Feb 13, 2015 at 6:16

0

You must log in to answer this question.