I tried accessing a webpage in a server within the local network with the host name of the device followed by its folder path and the name of the file(it is a basic php file) in first system.It worked as expected.
But when i tried the same in second system connected in the same local network ,i couldn't access it with the host name but i could access the page with the IP address of the server.
And ofcourse the second system's DNS was configured as the router which is the DNS for my local network.
Is there any additional configurations that i need to do for accessing the server with host name?
If you are using windows edit the file :\windows\system32\drivers\etc\hosts
If you are using linux the file is /etc/hosts
and add a line using the sintax already on the file
IPadress hostname
for example
192.168.10.100 www.mywebserver.com
save and done.
Related
I use 2 NICs card on my windows, one of the local and another one is connected to the internet, now my question is how can I set the specific browser to open just the Local website instead of the internet? I set the route command to route the IP address that I want to open locally but when I check the logs I find the IP open with internet NIC instead of Local NIC
There two methods of getting this done as per your request the first method would work for you:-
The first method:-
we can use static route route but we have to obtain the IDs for our NICs by running the command below:-
netsh interface ipv4 show interfaces
The above command will get you the NIC ID
Add a persistent route by using the command below in CMD this will lock the specified traffic from a specific network to the specified network interface using the NIC IDx see syntax command below via CMD.
route -p add local_subnet mask local_subnet_mask 172.132.45.201 IF
interface_ID
For example command below, please change the values as per your environment or network:-
route -p add 192.168.0.6 mask 255.255.255.255 172.132.45.201 IF 13
The Second Method:
You will need to edit your hosts file that will enable you to override the DNS for a domain on a specific machine.
Modifying your hosts file causes your machine to look directly at the IP address that you specify
Modifying the hosts file involves adding entries to it to the file . Each entry contains the IP address to which you want the site to resolve.
192.168.190.4 www.local_domain.com
192.168.190.4 local_domain.com
13.14.15.16 www.external_domain.com
13.14.15.16 external_domain.com
Below are the steps to edit the hosts file in Windows 10/11 and Windows Server 2012 and newer versions (you didn't specify which version of Windows).
Press the Windows key.
Type Notepad in the search field.
In the search results, right-click Notepad and select Run as administrator.
From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
Make the necessary changes to the file.
Select File > Save to save your changes.
For Windows, you may have to reboot your computer and this will work independently of the NIC setup.
I've got a single DNS entry which I want to map to an external IP address (the ip represent an active directory server running on amazon cloud). Unfortunately, the DNS server used in my organisation has different mapping and it send this URL to internal address (local network) and I don't have permissions to change it for all users.
So I've manually change this DNS entry in my local machine. However, every once in a while, it gets updated by the DNS server.
I tried disabling that updates with a Group Policy, but with no help.
Is there any way to permanently set this DNS mapping either locally (preferable) or in the DNS server for my machine only ?
Update your host file.
In windows:
c:\Windows\System32\drivers\etc\hosts
In Mac:
/etc/hosts
In Linux
/etc/hosts
Add your server there
123.123.123.123 domain.com
Your host file have precedence over the DNS query and is much faster.
Is it possible to block website from DNS Level. Is it possible to create DNS server in windows server 2012?
I know you can do it pre-DNS pevel. Prior to DNS lookup, windows will check the hosts file for IP to domain mapping. You can set facebook.com to 192.168.1.1 and it will use that ip for facebook rather than looking it up in DNS, and thus blocking it. This would require modifying the host file on every machine you want to sensor though. Its a file in the system32 folder.
I developed a client/server simulation application. I deployed client and server on two different Windows XP machines. Somehow, the client is not able to send requests to the server.
I tried below options:
Pinged server machine successfully from client using ip-address.
Pinged client machine successfully from server using ip-address.
Checked netstat command line tool from both machines. Server is in LISTENING mode and client is in SYS_SENT mode. But the foreign address it is using to send is host name not the ip address.
Pinged server machine unsuccessfully using host name from client.
Pinged client machine successfully using host name from server.
I feel the problem is when the client is trying to connect to the server using the host name.
Could you please let me know how to force an application to use an ip address instead of a host name? Is there any other way to map the host name to an ip address?
Go to your client machine and type in:
nslookup server.company.com
substituting the real host name of your server for server.company.com, of course.
That should tell you which DNS server your client is using (if any) and what it thinks the problem is with the name.
To force an application to use an IP address, generally you just configure it to use the IP address instead of a host name. If the host name is hard-coded, or the application insists on using a host name in preference to an IP address (as one of your other comments seems to indicate), then you're probably out of luck there.
However, you can change the way that most machine resolve the host names, such as with /etc/resolv.conf and /etc/hosts on UNIXy systems and a local hosts file on Windows-y systems.
Try tracert to resolve the hostname. IE you have Ip address 8.8.8.8 so you would use; tracert 8.8.8.8
You could use a C function getaddrinfo() to get the numerical address - both ipv4 and ipv6.
See the example code here
This is hard to answer without more detail about the network architecture. Some things to investigate are:
Is it possible that client and/or server is behind a NAT device, a firewall, or similar?
Is any of the IP addresses involved a "local" address, like 192.168.x.y or 10.x.y.z?
What are the host names, are they "real" DNS:able names or something more local and/or Windows-specific?
How does the client look up the server? There must be a place in code or config data that holds the host name, simply try using the IP there instead if you want to avoid the lookup.
Windows XP has the Windows Firewall which can interfere with network traffic if not configured properly. You can turn off the Windows Firewall, if you have administrator privileges, by accessing the Windows Firewall applet through the Control Panel. If your application works with the Windows Firewall turned off then the problem is probably due to the settings of the firewall.
We have an application which runs on multiple PCs communicating using UDP/IP and we have been doing experiments so that the application can run on a PC with a user who does not have administrator privileges. In order for our application to communicate between multiple PCs we have had to use an administrator account to modify the Windows Firewall settings.
In our application, one PC is designated as the server and the others are clients in a server/client group and there may be several groups on the same subnet.
The first change was to use the functionality of the Exceptions tab of the Windows Firewall applet to create an exception for the port that we use for communication.
We are using host name lookup so that the clients can locate their assigned server by using the computer name which is composed of a mnemonic prefix with a dash followed by an assigned terminal number (for instance SERVER100-1). This allows several servers with their assigned clients to coexist on the same subnet. The client uses its prefix to generate the computer name for the assigned server and to then use host name lookup to discover the IP address of the assigned server.
What we found is that the host name lookup using the computer name (assigned through the Computer Name tab of the System Properties dialog) would not work unless the server PC's Windows Firewall had the File and Printer Sharing Service port enabled.
So we had to make two changes: (1) setup an exception for the port we used for communication and (2) enable File and Printer Service in the Exceptions tab to allow for the host name lookup.
** EDIT **
You may also find this Microsoft Knowledge Base article on helpful on Windows XP networking.
And see this article on NETBIOS name resolution in Windows.
Is there any difference between the following when a intranet URL in accessed in IE
Add an entry in drivers/etc/host file for a name and IP
vs
Use IP directly
e.g. it works with the following link if I have a host entry as (XYZ 10.0.10.200)
http://XYZ/SiteDirectory/ABC/Default.aspx
but when I tried to use IP instead of name
http://10.0.10.200/SiteDirectory/ABC/Default.aspx
It gives me 404 not found error
Yes, there's a difference.
The web server is using HTTP/1.1 and "shared virtual hosting". When the client connects it sends an additional Host: header which contains the hostname part of the URL that the user supplied.
The web server looks at the header to find out which virtual host's data to serve.
In this case, the web server is configured to recognise and serve content from the "XYZ" domain, but doesn't know about any domain called 10.0.10.200
Smells like the webserver is using virtual hosts, so that it serves different pages if the client went to "www.foo.com" or "www.bar.com", even though they have the same IP-address.
As far as I can see there should be no difference. With a host name the order is hosts file before DNS so it should be used.
Is there another line in the host file with the same hostname?
What happens when you do a tacert? (trace route)