Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an Ubuntu Server 13.10 configured as a Virtual Machine host, using libvirt and KVM.

I have added two virtual machines, both using Ubuntu Server 13.10, one with Mysql and other with Apache/PHP, both are using NAT Network.

I have successfully configured NAT Forwarding ports 22 on both guests to 2222 and 2223 respectively, so I can access both virtual machines using SSH.

But both machines cannot access the internet, if I do something like "wget google.com" it finds out the IP of domain google.com it doesn't do nothing, no internet access at all.

How can i fix that?

My network interfaces:

eth0      Link encap:Ethernet  HWaddr 00:18:8b:df:79:bb
          inet addr:192.168.21.127  Bcast:192.168.21.255  Mask:255.255.254.0
          inet6 addr: fe80::218:8bff:fedf:79bb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:108308 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39778 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:26369386 (26.3 MB)  TX bytes:9500205 (9.5 MB)
          Interrupt:16

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12854 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12854 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:821796 (821.7 KB)  TX bytes:821796 (821.7 KB)

virbr0    Link encap:Ethernet  HWaddr fe:54:00:40:7c:07
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9047 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15743 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:882275 (882.2 KB)  TX bytes:17303440 (17.3 MB)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:bd:53:87
          inet6 addr: fe80::fc54:ff:febd:5387/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9048 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17195 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:1169688 (1.1 MB)  TX bytes:17463497 (17.4 MB)

vnet1     Link encap:Ethernet  HWaddr fe:54:00:40:7c:07
          inet6 addr: fe80::fc54:ff:fe40:7c07/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:831 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1981 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:184465 (184.4 KB)  TX bytes:321841 (321.8 KB)

My iptables forwarding rules:

sudo iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to-destination 192.168.122.252:22
sudo iptables -t nat -A POSTROUTING -p tcp --dport 22 -d 192.168.122.252 -j SNAT --to 192.168.122.1

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.122.252:80
sudo iptables -t nat -A POSTROUTING -p tcp --dport 80 -d 192.168.122.252 -j SNAT --to 192.168.122.1

sudo iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 192.168.122.253:22
sudo iptables -t nat -A POSTROUTING -p tcp --dport 22 -d 192.168.122.253 -j SNAT --to 192.168.122.1

sudo iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to-destination 192.168.122.253:3306
sudo iptables -t nat -A POSTROUTING -p tcp --dport 3306 -d 192.168.122.253 -j SNAT --to 192.168.122.1
share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.