Apache on Linux in Windows LAN

Posted on 2003-03-25
Medium Priority
Last Modified: 2010-03-18
Trying to get apache server respond to http://internal-unix-server/ on WinNT machines by browsers on the intranet. Planning to run a Twiki server on the Linux webserver to be accessable by WinNT workstations on intranet. IP address of the server is obtained through DHCP.

Current Situation:

Cannot start Apache 2.0.40 httpd with server name set to internal-unix-server. Have to use the IP address as server-name to start httpd. However, I'm using DHCP so this is not desirable.

I'm able to ping the internal-unix-server name (Samba running). I'm able to see the internal-unix-server in Network Neighborhood in WinNT.

If I use internal-unix-server as server-name in httpd.conf, I got the error message in the error log file:
   [alert] (22002)Name or service not known: mod_unique_id: unable to find IPv4 address of "internal-unix-server" Configuration Failed


Apache 2.0.40, Samba 2.2.7a running on Red Hat 8.0.

Question by:aeemycheung
LVL 17

Expert Comment

ID: 8209905
Your problem is DNS related.
You need to configure a local DNS server to point the name "internal-unix-server" to it's IP address.
What would complicate matters here is the fact that your Linux box is getting a dynamic IP via DHCP...
I'm not sure how to map a name to a dynamic IP, but others might have a solution for you.

The reason why your Linux box won't start apache with the name instead of IP is for exactly the same reason, it cannot resolve the name to an IP, once you have configured your name servers correctly, it will start.
I think by far the easiest way would be to give the Linux box a statis IP on the network, then either configure Linux as a nameserver, or use one of the windows servers as a nameserver and make the appropriate entry for the Linux box there. Then you need to tell all users on the network, Linux server included, to use the windows nameserver as the default nameserver.

Expert Comment

ID: 8211215
I think by far the easiest way would be to give the Linux box a statis IP on the network, then either configure Linux as a nameserver, or use one of the windows servers as a nameserver and make the appropriate entry for the Linux box there. Then you need to tell all users on the network, Linux server included, to use the windows nameserver as the default nameserver.

agreed.  the problem seems like the windows boxes don't know where the linux box is... to test this, try starting apache using the ip address (for example, then point the windows browser to that ip and this should bring up the page.  Then you know your problem is entirely DNS related within the network.

Author Comment

ID: 8214924
Thanks guys. I've already tried the static IP thing (that's not really 'allowed' in a DHCP network where other WinNT machines are using DHCP to get IP). What I need is the dynamic IP solution.

Somebody has already done something like this, basing on the question asked:

But I'm not sure how it's done. I do not need sophisticated authentication in my case though.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

tkalchev earned 300 total points
ID: 8218414
The best way for resolving your problem is somehow to find what is the dynamically assigned IP address at boot time, then to make the appropriate changes in /etc/hosts.

One solution is (Assuming your network interface is eth0, and the hostname is linux_server):

1.Create a file /etc/hosts.orig, where you should copy the contents of your /etc/hosts, excluding all records, containing your hostname  (linux_server).

2.Configure httpd.conf with
ServerName linux_server

2.Add the following at the end of /etc/rc.local :


DYN_IP=$(ifconfig $ETH | grep "inet addr" | awk '{print $2}' | awk '{split($1,e,":"); print e[2]}')

rm -f /etc/hosts
cp /etc/hosts.orig /etc/hosts
echo "$DYN_IP $HNAME" >> /etc/hosts

/sbin/service apache restart

So, on every boot you will have an actual /etc/hosts file and apache will not fail to resolve the IP address.

Expert Comment

ID: 8218598
Opps, above should be added to /etc/rc.d/rc.local not /etc/rc.local of course

Expert Comment

ID: 8289488
bypass dhcp...
1. see what ip info you have
less /etc/resolv.conf
route -n
2. edit your adapter info
vi /etc/sysconfig/network-scripts/ifcfg-eth0
    IPADDR="your ip address"
    GATEWAY="your gateway"
    DNS2="your dns"
3. tell the comp what its name is
vi /etc/hosts
    "your ip address"   internal-unix-server
4. apachectl start

Author Comment

ID: 8289919
Thanks, tkalchev. I have tried your suggestion has and it works fine. Is it a bit strange to have to restart the apache (httpd) service? Is it safe or good to play with the script that started the service the first time?

Futher problem,  the address has not been registered with the DNS yet, so although Windows NT machines are able to find the server with http://linux-server (I guess they used broadcasting), another Linux machine cannot find it. Is there some way I can register the name with the DNS? Or can I configure the other machines to use broadcast in order to connect to the linux-web-server?

Expert Comment

ID: 8290060
You need to restart apache in order to recognize the newly created binding between the hostname and the DHCP IP address. The worst case is that first apache cannot start with the error yo have specified, because it still don't know that "linux-server" is bound to the new DHCP IP address.

You can access the server from the NT machines, because they are using NetBIOS to find the names. Linux servers are not using NetBIOS, only the /etc/hosts and DNS lookup. One solution is to install a local DNS server and dynamicaly update the local zone file after every IP changing of the linux-server.


Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question