#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Posts
    9
    Rep Power
    0

    Virtual Hosts stop working when NIC is unplugged


    I'm having this extremely annoying problem where my virtual hosts work perfectly until I unplug my NIC/kill my internet connection/want to work on laptop with no connectivity.

    On my previous laptop, everything worked fine even when I was not connected to a network. I set up my new laptop, upgraded XP to sp3, reinstalled apache 2.2, PHP, MySQL (this is not a wamp install). I copied over all the same config files from the old computer (etc/hosts,httpd.conf,httpd-vhosts.conf) and I believe I restored internet settings from old machine to new machine also.

    So everything works just fine, until I disconnect from my LAN/WAN. I have a small office LAN with a dsl router as gateway, and the router provides DHCP. NIC is set to acquire both LAN IP and DNS IPs from DHCP server (router). My laptop sits in a dock, network connects to dock.

    While connected, I can go to localhost where I get the generic "It works!" page that Apache creates at install. I can also go to one of my local project sites, for example project1.local, which brings up the site as served locally by apache. No problems so far.

    Now, if I pull my network cable or use my laptop on its own with no network connectivity, a very strange thing happens. I can still go to localhost and see the default apache It Works page. However, my virtual hosts stop working. Sometimes I just get a browser "seems to be no internet connection" message, with the virtual host remaining as typed in address bar. Sometimes the "project1.local" I typed into the address bar gets refreshed to "w w w.project1.local" (not a real URL, devshed - doesn't break the new user rules) ... Sometimes the browser checks the "working offline" file menu item and sometimes it doesn't.

    ==========================================
    I think these are all the relevant config settings as I have them:

    HTTPD.CONF (F drive)
    Listen 80
    ServerName localhost:80
    Include "F:/appData/apache/2.2/conf/extra/httpd-vhosts.conf"

    HTTPD-VHOSTS.CONF (F drive)
    NameVirtualHost *
    <VirtualHost *>
    ServerName localhost
    </VirtualHost>
    <VirtualHost *>
    DocumentRoot "F:/apache_webroot/cs130b/htdocs"
    ServerName project1.local
    ServerAlias project1.local, *.project1.local
    ErrorLog "F:/apache_webroot/cs130b/logs/cs130b.host-error_log"
    CustomLog "F:/apache_webroot/cs130b/logs/cs130b.host-access_log" common

    <Directory "F:/apache_webroot/cs130b/htdocs">
    Options Indexes FollowSymLinks All
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    Include "F:/appData/apache/2.2/conf/extra/httpd-php5-2-4-cgi.conf"

    </VirtualHost>

    ETC/HOSTS (C:\windows\system32\...)
    127.0.0.1 localhost
    127.0.0.1 project1.local
    127.0.0.1 admin.project1.local
    127.0.0.1 test.admin.project1.local

    ==========================================

    I don't see anything in the host's error log about it. Some error messages show up there from PHP when the virtual host is working, but nothing gets added to the log when the virtual host stops working. Apache is still running as a service. It's as if the browser is no longer getting DNS info, but the info is right there in my etc/hosts file and the localhost loopback still works with apache still serving up that default localhost page.

    Another change from my old system in addition to XP sp3 is that I now have Kaspersky Internet Security running. But the problem is unchanged whether I have Kaspersky set to scan web traffic or not, and even if I pause protection and it isn't doing anything.

    I've looked at other forum posts but haven't found anything that seems to quite match this. Any help would be appreciated.

    Added:
    - Windows firewall is not running
    - IIS is not installed. It was installed on the previous computer, but then I stopped running the service after switching to apache, so new computer is more or less the same in this respect.
    - Apache is installed on a partition P: and the config files and all document roots for virtual hosts are on another partition F. P, F, and the C drive are all on the same hard disk. There are no network shares involved. The apache httpd.conf file in the actual apache install dir is, in its entirety:
    Include "F:/appData/apache/2.2/conf/httpd.conf"
    - I get the same behavior from Firefox, IE, Chrome, and Opera

    Comments on this post

    • jharnois agrees : Welcome to Dev Shed.
    Last edited by patrickthx; January 2nd, 2009 at 12:58 AM. Reason: Addendum
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Posts
    9
    Rep Power
    0

    DNS Client service


    I think I solved this. I discovered that the windows "DNS Client" service was not running. Once I started it, I was able to get responses from not only localhost but also my project1.local virtual host. I'm not sure why a local etc/hosts dns lookup was taking place while connected to the internet but DNS Client disabled, but I guess that's windows for you. And I guess in pre-sp3, this service was enabled by default.

IMN logo majestic logo threadwatch logo seochat tools logo