LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Configuring 2 Ubuntu VM (networking) (https://www.linuxquestions.org/questions/linux-networking-3/configuring-2-ubuntu-vm-networking-815037/)

alee 06-18-2010 10:11 PM

Configuring 2 Ubuntu VM (networking)
 
Hi,

I have latest ubuntu and I have made 3 vm's for them.

VM 1: with 2 NIC cards, one is NAT connected directly through my host machine to the internet with ip address 192.168.190.142. Second NIC card is "host only" with ip address 192.168.0.10

VM 2: with 1 NIC card, "host only" and ip address 192.168.0.100

I want VM 2 to connect to the internet but through VM 1. for this I used following configuration in
Code:

/etc/network/interfaces
but it is not working

Code:

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
    address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.10

I have given my VM 2 the gateway of VM 1 but it is not going through. Am i doing something wrong. Could someone please help me?

P.S:
both machines are pinging each other properly.

tkmsr 06-19-2010 02:31 AM

When we read your question we are completely clueless as what you are asking

1) You are using Xen,KVM or which type of hypervisor ?
2) When you say VM1 I think you mean to say the real operating system which is host for the guests is it correct?
3) Can you describe some thing about your network topology bridged,NAT,






Code:

                                |--------------192.168.0.100
                                |           
                                |
                                |
                                |
                                |
                                |--------------192.168.1.4
                                |           
  (Public IP )    (KVM)        |
            A-------------------|
                                |
  (192.168.190.142)            |
  (192.168.0.10                |--------------192.168.1.5
                                |           
                                |
                                |
                                |
                                |
                                |
                                |
                                |--------------192.168.1.19
                                |


4)
Quote:

Originally Posted by alee (Post 4008180)
Hi,


P.S:
both machines are pinging each other properly.

Which are these two machines.

5) Are you saying the host Operating System also as VM or only guest OS?

alee 06-19-2010 10:17 AM

Okay, I might have put the question in a wrong way.

- I have 1 physical machine which is running Windows 7 64 Bit.
- I have installed VMWare on it.
- I have created 2 VM (Virtual Machines). VM 1 (Ubuntu 10.04) and VM 2 (Ubuntu 10.04)


Code:




                                  192.168.0.10 (eth2)                          192.168.0.100 (eth1)
Windows 7 ------------------ VM 1 (2 NIC Cards)--------------------------- VM 2 (1 NIC Card)
(host)                        192.168.80.132 (
                            eth1 - NAT with Host Machine i.e.
                                  windows 7)

The VM1 machine, is able to use internet properly.
- 2 Machines (VM 1 and VM 2) are able to ping each other i.e.
Code:

ping 192.168.0.10
from VM 2 work fine and
Code:

ping 192.168.0.100
from VM 1 work fine

I want my VM 2 to access internet through VM 1.


I hope i am clear this time

tkmsr 06-19-2010 12:01 PM

Quote:

Originally Posted by alee (Post 4008548)
I want my VM 2 to access internet through VM 1.

Then you need to configure Squid on VM1
Google Squid.

alee 06-19-2010 12:59 PM

emm .. are you sure? it should not be that complex thing .. :s

alee 06-19-2010 12:59 PM

okay let me put this way. I don't want to set up a proxy server. I want to share the connection which is being used by VM1.

SuperJediWombat! 06-19-2010 06:47 PM

From VM1 run these commands:
Code:

sudo bash -c 'echo "1" > /proc/sys/net/ipv4/ip_forward'
sudo iptables -t nat -A POSTROUTING -o eth1 -s 192.168.0.0/24 -j MASQUERADE

That assumes that eth1 is the 'external' interface for VM1 (whichever interface is connected to the internet through the windows7 host)

alee 06-19-2010 09:34 PM

i did the ipforward thingy but have not tested the iptables. will test it .. thanks though

SuperJediWombat! 06-20-2010 08:49 AM

You will also need to set VM1 as the default gateway for VM2


All times are GMT -5. The time now is 11:55 AM.