Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ubuntu server (natty) is running on my Ubuntu (natty) by VirtualBox OSE, How to only I can access my server NOT every internal IP in my LAN and both can access the internet. now I sharing the Internet by bridge, It's good for access my virtual server. but everyone on my LAN can see too.

share|improve this question
I tried NAT before, I and my virtual server can access the Internet but they cannot access each other. (or It's possible but I don't know how to do it?) – Smile.Hunter Aug 2 '11 at 11:47
My access term is mean I can browses my website (port 80/apache) on my virtual server. – Smile.Hunter Aug 2 '11 at 11:59
up vote 1 down vote accepted

Another possibility is to use NAT networking and forward port 80 to your VM.

That way your server should be able to access everything (internet and LAN), your server will not be visible to your lan. Connections to the port 80 of your real computer will actually connect to port 80 in your virtualised server.

You can check your web server from your host (real computer) pointing a browser to localhost.

You configuration should look like this: enter image description here

Note that you don't need to fill the IP field.

share|improve this answer

So, lets see if I understand your requirements:

  • Other LAN computers must not be able to access your server.
  • Your server must be able to access the internet.
  • Your host (Ubuntu box with virtualbox) must be able to access the internet (of course).
  • Your host must be able to access the server (which is a VM).
  • It's OK if your server can access other hosts on your LAN.

Probably the easiest way to do this is using the bridging option. Then on your server, set up UFW (Uncomplicated FireWall) to Drop (the GUI for UFW, called GUFW, calls this DENY) traffic from your LAN. Of course, make an exception for the host. This should block traffic to your VM from your LAN except pings. If you want to block pings, you may have to tweak some of UFW built in rules. (I could add more about this if you need it).

The other option is to set up a shared interface between the host and VM. Then on the host make an /etc/network/interfaces with a static address. You would do the same on the VM (except with a different address). Then you would login to your router for your LAN and add a route to the address block you used for your VM/Host shared interface using the host computer as the gateway. (You will probably want to have the host connect to the router with a static address so that you don't have to change the route all the time). You'll want to edit /etc/sysctl.conf as root and set ip.forward to =1. You would then set up UFW on the Host to Drop packet from the LAN destined for your server. (I'll expand+add details to this second option if you decide you want to do it this way and ask).

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.