Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello. My first post here and i'm new to Linux/ networking so sorry if this is a daft question.
I have set up a home network using a modem/router, which my devices connect to via ethernet and wireless. I have got it working but i'm still not happy (stick with me...)!
I have settings configured so as to utilise DHCP, so IP addresses for the different machines are automatically assigned by the modem/router (as i understand it). I then obtained these auto-assigned IPs by running ifconfig on each device. I tested connections between the devices by pinging each other using these IPs (ie ping 192.168.2.2).
BUT I want to be able to use hostnames (ie ping dandelion) instead, and the only way I can make this work is to add hosts and corresponding IPs into the /etc/hosts file.
I have made it work in this way, but doesn't this method defeat the idea of DHCP, as I will now presumably have to manually maintain the /etc/hosts files on each device.
Depending on your router, there may be a setting that allows you to make the addresses that it assigns permanent. For example on my router, next to the ip address assigned to each machine, it has a checkbox that is labelled "always use this address".
Yes, once you've achieved that, you will have to edit your /etc/hosts file on each machine, but unless you keep changing the hostnames, you will only have to do it once.
Please use the correct format for hostnames i.e. host.domain.com in your /etc/hosts file as it will avoid problems later. You don't need to have a genuine domain for this as it only gets used inside your network. But once done you can use http addresses of the same format to access each machine with a browser (once apache is set up of course).
Also make sure you set the hostname on each machine properly. There are several places it needs to be changed if you do it manually, but depending on your distro, there is usually a GUI network config tool that allows you to set the hostname and add entries to /etc/hosts.
There is a difference between netbios names and FQDN's. Hosts files are really for static situations. They can be used in your situation but as you say, you'd have to either mark the systems as lease forever or always issue or relay information back to your linux system with changes like you seem to be suggesting.
I think I'd set to forever lease and or always assign if possible as noted above.
Cheers guys i've set leases to permanent, which seems to be the best option at the moment. I can't really see much difference than setting fixed IPs though with this method.
I thought I would be able to set it up so that the router holds the IP addresses and hostnames, and then does the resolving for me like an internet DNS would; avoiding the need for the /etc/hosts files on each PC.
Is this possible or have I misunderstood how it works?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.