Hi guys,

I want to access my virtual domain from another computer on same network by typing or without using IP at the beginning of URL.

Currently it works this way:

Server computer where Apache is running: AND works fine as I want.
Another desktop computer on same LAN : works only this way.

What should I do to remove that IP from URL and htdosc bit?

I added my configuraton so you know what I did. I use Ubuntu 10.10

Thanks in advance

/etc/apache2/sites-availabe/site1.com.conf

<VirtualHost *:80>
	ServerName	site1.com
	ServerAlias	www.site1.com
	DocumentRoot	/var/www/site1.com/htdocs

	ServerAdmin	admin@site1.com
	ErrorLog	/var/log/apache2/site1.com_error-log
	CustomLog	/var/log/apache2/site1.com_custom-log	common
</VirtualHost>

/etc/hosts

192.168.31.28	ubuntu	# Added by NetworkManager
127.0.0.1	localhost.localdomain	localhost
::1	ubuntu	localhost6.localdomain6	localhost6
10.0.0.2	#ubuntu
127.0.0.1	site1.com	www.site1.com

I created link in /etc/apache2/sites-enabled
I did sudo a2ensite site1.com.conf
I have bind9 installed, if it helps.

Extra information:

myname@ubuntu:~$ sudo ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 54:42:49:87:10:e6  
          inet addr:192.168.31.28  Bcast:192.168.31.255  Mask:255.255.255.0
          inet6 addr: fe80::5642:49ff:fe87:10e6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:45807 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4279 errors:0 dropped:0 overruns:0 carrier:7
          collisions:0 txqueuelen:1000 
          RX bytes:4439887 (4.4 MB)  TX bytes:609477 (609.4 KB)
          Interrupt:49

Dani AI

Generated

Quick summary and practical steps (two options)

is right: the simplest fix for a handful of machines is to make the client(s) resolve the site name to your server’s LAN IP. is also right: if you want the name to work for every machine on the LAN without editing hosts files, run a small local DNS (BIND) and add forward/reverse zones. Below are troubleshooting checks and compact examples you can apply now.

Verify name resolution and Host header handling

  • From a client, confirm the name resolves and the Host header reaches Apache:
    ping site1.com
    nslookup site1.com
    curl -I http://site1.com/
    curl -H "Host: site1.com" http://192.168.31.28/

    If ping or nslookup do not show 192.168.31.28, the client is not resolving the name correctly. After editing a hosts file, flush the client cache (Windows: ipconfig /flushdns, Linux/macOS: restart the DNS/cache service or the browser).

Quick hosts-file approach (easy, per-client)

  • Edit the client’s hosts file as admin and add a line mapping the name to 192.168.31.28, then flush DNS. This is the fastest way when only a few clients need the site.

Local DNS (BIND) approach (scalable)

  • Add a forward zone and reverse zone to BIND and create A and PTR records. Example zone declaration:
    zone "site1.com" { type master; file "/etc/bind/db.site1.com"; };
    zone "31.168.192.in-addr.arpa" { type master; file "/etc/bind/db.192.168.31"; };

    And in the forward zone define @ and www A records pointing to 192.168.31.28. Reload bind9 after changes.

Apache checklist

  • Ensure name-based vhosts are enabled (Apache 2.2 needs NameVirtualHost *:80), the site is enabled (a2ensite + reload), and port 80 is reachable (firewall). Use a curl -H "Host: site1.com" test to see which vhost responds.

Common pitfalls

  • Editing the server’s hosts file only won’t affect other PCs. Don’t forget to flush DNS caches, and check for browser/proxy caching. If problems persist, include the output of ping site1.com, nslookup site1.com, and curl -I for further diagnosis.

Recommended Answers

All 6 Replies

It looks like your DNS configuration may need changing as your URL isn't being resolved across the LAN. Check your named.conf file and set up your forward and reverse lookup zones.

This link seems to answer what you're asking :)

Hello,

If this is only for the one other desktop then add an entry to the etc/hosts file on the workstation that points to 192.168.31.28.

If it is a linux system then the file is /etc/hosts
If it is a Windows system the file should be in \windows\system32\drivers\etc\hosts

Or check the following site for any OS http://en.wikipedia.org/wiki/Hosts_%28file%29

Thanks for reply guys. When I get back home from holiday, I'll try ıt and let you know about it. Thanks

Hi again guys,

1. I addedd to hosts but nothing changed.


2. I add my named.conf file. What exactly do I need to add to it?

Thanks

named.conf

// prime the server with knowledge of the root servers
zone "." {
	type hint;
	file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912

zone "localhost" {
	type master;
	file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
	type master;
	file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
	type master;
	file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
	type master;
	file "/etc/bind/db.255";
};

This is how I access from another computer at the moment:

I prefer and/or

Not sure if you have solved this yet but I may not have made it clear that the entry for the etc/hosts file goes on the PC that you are trying to access the site from as opposed to the server. That way when you enter the domain-name on the Workstation it pulls the IP address from etc hosts instead of looking the address up via DNS. Hope that helps.

Ahaaa. Sounds like, all the client machines should have hosts file with correct settings. Setting it up on server machine only is not enough then. Thanks for info rch

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.