Is a network device hostname determined by the device itself or a network admin? - hostname

I have a local network with several PCs and specialized controllers on it. These specialized controllers must be configured with static IP addresses and do not have DHCP capabilities.
I was asked to put together a list of the device hostnames and IP addresses. It's easy to figure out the IP address of each device, however, I'm struggling to find out the host name for these specialized controllers. If it were a Windows PC, I would simply navigate some menus to find the host name.
I'm confused about how the host name is configured for network devices in general. For Windows PCs, it seems like the PC itself determines its own host name. When it joins a network, it simply broadcasts its host name to a DNS server and the DNS server remembers it. For devices that are not DHCP, it seems like I would need to manually go to a DNS server and enter the host name for the specific IP address.
So what exaclty determines the host name? The device itself or a network admin?

This more of networking question and belongs to ServerFault - you will get your answer faster there.
If it were a Windows PC, I would simply navigate some menus to find
the host name.
What kind of system is there if there is no Windows? Linux, *BSD, AIX, other? I'll answer for Linux for now.
So what exactly determines the host name? The device itself or a
network admin?
This depends on your configuration in Linux check - /etc/nsswitch.conf
e.g.
hosts: files dns
Which defines that the hostname will be defined by /etc/hosts and if it is not found there it will check DNS next.
If hosts file, the local resolution, contains the pair ip <-> name it is used. If the DNS takes precedence and it contains the pair it is taken from there. As shown above, it can contain both at once in defined order, then the resolution is done in that order.
By the way, DHCP server can give you static IP addresses based on your MAC address so your controllers will have always the same IP address, if same network card is used. It is way easier to manage than configure all servers manually.

Related

Setting domain name for ip address on pi (Apache, DHCP)

I set up my pi to broadcast it's own "wifi" and I have an Apache server running on it.
I used this tutorial https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point
I can currently connect to the network that the pi is broadcasting and go to the ip of the server on my phone and it brings up the webpage, but I want to be able to type in "mydomain.net" and have it bring me to the webpage. Can anyone help me with this or suggest anything?
I want anyone that wants to connect to this local wifi (not worldwide) to be able to enter the website so changing everyone's host file is not going to happen.
you can modify /etc/hosts file on your local machine to point the custom domain name to the IP address of the environment you want to test. The /etc/hosts file contains a mapping of IP addresses to URLs.
Your browser uses entries in the /etc/hosts file to override the IP-address-to-URL mapping returned by a DNS server.
This is only useful for testing DNS (domain name system) changes and the SSL configuration before making a website live.

Accessing remote devices with dynamic IP

I need to access about 15 devices remotely with a software in a single server.
All these devices are connected to the internet through modems and I can access them, privided I have the modem IP. But most of these modems have dynamic IPs that usually changes more than once a week for various reasons.
I tried using dynamic DNS, but it doesn't work because the software accepts only IPs in the format XXX.XXX.XXX.XXX in its configuration.
Is it possible to configure a DNS server (or any other tool) to point to one of my dynamic DNS when asked for a specific IP address in my local network? I was going to try it but my Windows server fails to install the DNS server role, so I want to know if I should even bother solving this other problem.
In other words I want to do this: local IP -> global name address -> global IP address
Example: 192.168.1.100 -> dynamic.name.com -> 200.100.10.27

Does the hosts file affect to adhoc connected devices?

I've got a local Apache2 server on Ubuntu 12.04
with virtual hosts, so in the 'hosts' file I pointed
the virtualhost name to the local IP address -192.168.1.33-.
So 'http://mySite.local' points to '192.168.1.33', it works fine
in the browser.
Now I want to test the same in a cellphone connected to the machine
through a wlan-adhoc network created in my notebook with shared connection.
I can see the root folder if I access to '192.168.1.33' correctly,
but not if I access to 'http://mySite.local'
I assume the '/etc/hosts' file is not affecting the traffic through the adhoc network.
is this correct? Can I change this behaviour? is possible?
You are correct to assume that the hosts file only affects connections that originate from the machine to which the host file belongs. Other traffic already needs to know the IP address it will need to connect to before it reaches your machine. Depending on how much access you have to your phone, getting it to recognize your own domain name like this maybe more work than it's worth.
I say this because you would need to do one of the following:
Edit the equivalent of the hosts file on your phone (if such a file exists in an accessible way)
OR
Set up a local DNS server to serve this info to your phone AND get your phone to use it for DNS resolution.
Without knowing what phone you have, I can't say for sure how hard either of these will be. But I would guess neither one is going to be nearly as easy as typing in the IP and bookmarking it in your phones browser.
The hosts file only works for the machine it is local on. It is not passed on or used as a data source for any DNS service. You would have to have a hosts file local to your cellphone, and I'm not sure that this is possible.

Broadcasting hostname and IP address

In order to notify all computers within the same LAN about my existence, I want to broadcast my hostname and IP address.
How do I go about doing so without sending them as a string?
Avik, this is what DNS is meant to be used for. While "regular" DNS is meant to hold names and IP addresses for each machine (statically configured), there is a dynamic DNS protocol which allows machines to update their DNS entries in real time.
This sort of capability is used in some of the office environments for my clients where printers on a machine are shared but the machines they're attached to use DHCP (meaning their IP address can change).
See here and here for details and the Windows implementation with DHCP.
Lets call your machine that wants to advertise itself the SERVER and all the machines that can use it, the CLIENTS.
Of course, dynamic DNS only notifies DNS itself of the name/IP mapping and is useful if the CLIENTS are already aware of your SERVER so they can get the IP address from DNS. If you have no way for CLIENTS to discover that your SERVER has just been added, you'll still need to broadcast a packet occasionally indicating that your SERVER exists (this will only need the SERVER name since CLIENTS will use DNS to get the IP address).
This broadcast packet should be picked up by all CLIENTS and kept in a local table. If the communications from a CLIENT to your SERVER fails, the local table entry for your SERVER should be removed (it'll be re-added when your SERVER broadcasts again).
Basically re-inventing NetBIOS or ZeroConf, as popular with small embedded devices for discovery by a Windows or OS X based installer or setup utility.
You can try to use UPnP Discovery.

192.168.0.71... What is this special address used for?

I have some accesses from 192.168.0.71 on my apache logs. I looked up this IP (because my server almost exclusively takes requests from 127.0.0.1, and I saw that it's reserved for "special purposes." What types of purposes might those be?
Edit:
I didn't tell you, typing 192.168.0.71 brings me straight to my site, just as 127.0.0.1 would. I just wonder how this is different, then from 127.0.0.1.
RFC 1918 reserves addresses starting with 192.168 for private networks. This most likely means that some computer on your local network is accessing the server.
I didn't tell you, typing 192.168.0.71 brings me straight to my site, just as 127.0.0.1 >would. I just wonder how this is different, then from 127.0.0.1.
That means that 192.168.0.71 is the assigned internal IP to your machine.
127.0.0.1 is just a local loopback redirect. 192.168.0.71 is actually directly connecting to your machine.
192.168.???.??? is a special, reserved range of addresses private IP addresses. So it's probably a computer from your local network.
Read: http://en.wikipedia.org/wiki/Classful_network
EDIT:
You've edited your post.
It seems, it's your address in the local network.
127.0.0.1 is the loopback address.
Difference between them is if somebody else from your network types 192.168.0.71, they go to your site, 127.0.0.1 is for their computer.
192.168.0.71 (Well the entire range 192.168.0.0 – 192.168.255.255) are for private (read. not internet accessible) network IP addresses, so that is from something inside your private network.
I believe it is reserved for any private intranet, as per this document.
The 192.168.x.y block is typically used for non-Internet connected devices. It's most likely from one of your own machines. If you have a router of some sort, go into its configuration tool and see if you can find the block of addresses it uses to assign to internal machines. It should be 192.168.x.y.
Judging from your edit, it sounds like 192.168.0.71 is your computer's IP address on your internal network.
As to why it's showing up in your logs instead of 127.0.0.1... well, I can only assume that, for whatever reason, one of the programs on your computer is contacting the computer by its network IP rather than the localhost IP.
The 192.168.0.0 network is defined as being one of the "private" networks.
As Krzysiek Goj has said, check this link for further details.
There are 3 ranges that have been designated as private ip addresses.
- 10.0.0.0/8 (meaning 10.0.0.0 to 10.255.255.255)
- 172.16.0.0/12 (meaning 172.16.0.0 - 172.31.255.255)
- 192.168.0.0/16 (meaning 192.168.0.0 to 192.168.255.255)
Typically a DHCP server on your network (of which most network switches are examples) are configured to dynamically hand out ip addresses in one of the private ranges. The 192.168.0.0/16 range is probably the most popular. Alternatively you may have been statically allocated one of these addresses by your network administrator.
To check the address that you've been allocated you can use one of the following:
- (windows) ipconfig /all
- (unix) ifconfig
By default your machine will also have a loopback interface enabled using the address 127.0.0.1. This can be used to access your own machine.
There is not enough information here to completely answer the question. The most likely answer is:
The web server is also your desktop system. Your browser is running on that system as well, so the the 127.0.0.1 traffic is from your surfing of your own site.
The 192.168.0.71 is the actual IP address of your desktop, which is connected to some kind of NAT'ing device which connects you to the internet. Almost every broadband WiFi device uses this subnet by default.
The reason some traffic comes from that address is that on occasion, for various web reasons, some of the traffic is directly addressing your 192.168.0.71 address rather than the 127.0.0.1 address.