Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I have been trying to solve this problem (on and off) for three months, but still can't get it to work or even understand it why it happens.


I have a VirtualBox installed in my {HP 32bit, Windows 7} Laptop

In this VB, I've installed CentOs 6.5 minimal, Nginx, PHP-FPM with no problems.

In short, everything works well.


The problem is I can only access locahost if I am connected to the Internet.

While connected to the Internet, If I go to everything works, I can see my files like index.html just fine, but as soon as I am go offline, I get nothing, as if I was trying to access Google without being connected to the Internet.

This is a screen shot of my Vbox settings.

**Also here is the config for /etc/sysconfig/network-scripts/ifcfg-eth0

I have done the following various times.

Tried with iptables disabled/enabled
Tried with Host Only, NAT Bridged Adapters
Tried with Static IP, and DHCP..
refreshed networks several times

I am sure the answer is somewhere, because I still don't have the perfect setup configs, but mixing many things as I go, so still can't get it to work.

share|improve this question

migrated from Mar 8 '14 at 15:42

This question came from our site for system and network administrators.

up vote 0 down vote accepted

In the VirtualBox Network settings, you have the CentOS machine 'bridged' onto your WiFi network, with a static IP address.

Your laptop won't have a fixed IP address on its WiFi connection; when you are not connected to WiFi, Windows has no network connection up and running and doesn't know how to get to the CentOS server. When you connect to WiFi your router gives Windows an address on the same network and then it can get to the CentOS server.

They are running on the same computer, but they are separate and can't automatically talk between each other. The fix is to change the networking setup somehow, and how you change it depends on what you want to do.

The easiest way might be to go to Windows Control Panel, Network Connections, then find your wired network adapter (assuming your laptop has one and you don't use it), and go to the properties and set a TCP/IP network address of, subnet mask of, no gateway.

This will pretend your computer is always on the same network as the CentOS machine and can always get to it, yet should still allow the WiFi connection to take over and be your internet connection when you use it, and still allow CentOS to get out to the internet when WiFi is connected, and still allow other computers to connect in to CentOS, and still allow your computer to work on other WiFi networks, but it will stop your wired connection from working in as many places.

There are other approaches you could take, but they will all affect one or more of these use cases, and require more work to put right afterwards.

[Edit: I am ignoring where you say "can't access localhost". That might be important. You should describe exactly what your test is - which computer are you using, what software are you loading, where are you typing localhost?]

Edit: New suggested configuration

This involves having a separate, two-computer network just for Windows to talk to CentOS.

  1. In Windows, in the image you showed here - go to the properties of the VirtualBox Host-Only Network adapter, into Internet Protocol TCP/IP v4 properties, and set an IP address of and a subnet mask of, leave the other settings empty, and OK out of it.

  2. In the CentOS Virtual Machine settings (with it powered off), go to the Network settings and set Adapter 1 to "Host Only Adapter".

  3. Power on the CentOS machine. Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 and set IP address and subnet mask of Have no gateway, no DNS servers. Restart the networking or restart the CentOS machine.

You should now have this new, separate network of -- to talk between them. Run your NGinX so it listens on the address, and visit in Windows to get to it.

This should work with or without WiFi. The only problem is that CentOS cannot get to the internet to do updates or installs. If this is a problem:

  1. Power off the CentOS machine and go to the VirtualBox settings for it, in Network. Choose the Adapter 2 tab, enable it, set it to Bridged Adapter.

  2. Power on the CentOS machine, and configure an eth1 interface. Configure this to get an IP address dynamically / by DHCP. I use system-config-network-tui but I had to install it. You might be able to copy /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth1 Restart the networking make sure it comes up.

It should have a network connection joined to your WiFi like the original one that only works when WiFi is connected, but CentOS can use it to get to the internet.

share|improve this answer
Sorry for the delay, I asked and went for a while. Anyway Thank You! I have got a feeling you finally can help me. But I have one problem: I can't find the Wired Network Adapter in my Win7 I went to this Control Panel\Network and Internet\Network Connections and only found these networks I even tried with some by modifiying the IP, but it does not seem to work – user2679413 Mar 8 '14 at 23:06
Hmm; Picture extremely useful, thanks. You don't have a wired connection. I'm not sure if this will work, but go into the properties of "Wireless Network Connection", then click "Internet Protocol Version 4 (TCP/IP)" and click the properties button, then go to the tab "alternative configuration" and set user configured, just put IP address and subnet, OK out of everything. Hopefully your laptop will use this address when not connected to WiFi, and will still pick up an address and work properly when connected to WiFi. – TessellatingHeckler Mar 9 '14 at 0:04
I think we may have slightly different OS, as mine does not have "Alternative Configuration" tab, I only have have one general tab, and I filled the numbers (though your ip suggestion ends 101, but what worked for me earlier ends with 100) At the end still nothing, I can't get it to work. I am upvoting you for your effort, I will just keep trying I guess. – user2679413 Mar 9 '14 at 0:36
We do, my only wireless device is Windows 8. On the screen you show, behind the 'advanced' button there's an option for a "secondary IP" and I would have suggested putting it there. But if you tried filling in the numbers on the screen you show and it didn't work, that's more of a problem. You have showing in your CentOS eth0 config, so you can't use that address on your Windows 7 computer networking as well, so I suggested the next one up. Windows does not have an address on 192.168.1.??? unless it's on WiFi, I hoped you could give one that it could always fall back to. – TessellatingHeckler Mar 9 '14 at 0:56
Nope nothing works. This problem has cost me many hours already. Anyway, as a last resort, is there any way I could do to make it work, with another method? I don't know what vagrant is, but it might be another way of running VM on my machine, or how about if I use NAT, HOST Only bridges? I'm trying to change my WAMP enviroment, so any help will do as long as I can run a web server and php using centOs – user2679413 Mar 9 '14 at 1:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .