Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make IP address of virtual box same as that of my base os

I have Windows7 as my base operating system. On top of that I installed Virtual Box with Ubuntu. I want ubuntu to get same IP address as that of my base os (Win7). How do I achieve this? Any idea?

Thanks, Saurabh.

like image 505
Saurabh Avatar asked Feb 20 '13 05:02

Saurabh


1 Answers

Oh yes you can! Exactly how you setup a server behind a router/firewall. paxdiablo was right somewhat. If both the host and the guest(s) share the same port, the TCP/IP stack does not know where to send the packet. But if you're having only the guest handling a specific port than it becomes trivia - just forward the host's port to the guest's port (exactly like what you'll need to do in configuring a router).

In my case, I am running VirtualBox on Win7 and have a guest running an linux distro. Only the linux distro is running a WebGUI, so the network setting I used was NAT. Then here comes the fun part, under the NAT option, select "Port Forwarding". From there you can add the host's IP address (192.168.1.123) and the guest's IP address (10.0.2.15 in my case), but have port 80 from the host forward to the guest's port 80. It works like magic! You'll need to do this for every port your guest listens to.

If you have more than 1 guest that listens to the same port, (e.g. 80), then you'll have to designate another port from the host and forward that to the guest. (e.g.: 8080 from the host to port 80 of guest #2's IP) Any external devices that connects to guest 2 will be at http://192.168.1.123:8080.

Now you can have (almost) as many guests sharing the same IP as you want. Hope this helps.

Jim Chan

like image 191
Jim Chan Avatar answered Sep 24 '22 15:09

Jim Chan