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.
I've setup a dhcp server and it's running fine. I was wondering if i could set it up so that when a client requests an IP it gets any IP from the pool, however, the client's hostname (set on the client side) is also bound to this IP?
edit:
I think I'll have to use the "get-lease-hostnames" in /etc/dhcpd.conf somehow to dynamically modify the /etc/hosts file.
Does any1 know how I can use "get-lease-hostnames" in /etc/dhcpd.conf to add the DHCP assigned IPs along with the clients' hostnames to /etc/hosts?
Is this a good idea? or would it be a security risk?
I wish to implement this on a local network behind a router/firewall linux box which is also doubling as the DHCP server. The clients on the LAN are mixed (win/lin boxes).
I use ISC bind and dhcpd set up with secure dynamic updates. As a lease is granted, dhcpd also updates the DNS forward and reverse zones with the right info. No hosts files needed. The problem is then how to integrate this local DNS server in to the LAN so all clients use it, and have the server pass queries to the right place.
Check out the dhcpd.conf man page - Dynamic DNS Updates.
The dhcpd.conf man page details how to configure dhcpd for dynamic updates. Section 4.2 of the Bind 9 Administrator Reference Manual covers the bind half of the equation.
If you already have bind running well and on the same box then integration is fairly simple: What it boils down to is adding a few lines to dhcpd.conf to set the update style to "interim", declaring a security key to use and defining the zones to update. Here's the end of my dhcpd.conf:
+++++
# DDNS
ddns-update-style interim;
# For debugging, logging, etc.
# update-optimization off;
# Key split out for security and chroot operation
include "/etc/dhcpd.key";
zone localnet. {
primary 127.0.0.1;
key dhcpdkey;
}
zone 0.168.192.in-addr.arpa. {
primary 127.0.0.1;
key dhcpdkey;
}
-----
The key file was generated with dnssec-keygen.
For named.conf, add a line to include the same key file and add a line to allow secure updates in the forward and reverse zones for your local (dhcp) network. e.g.
+++++
include "/etc/dhcpd.key";
zone "localnet" IN {
type master;
file "localnet.fdb";
allow-update { key "dhcpdkey"; };
};
// Main reverse local zone maintained by dhcpd
zone "0.168.192.in-addr.arpa" IN {
type master;
file "localnet.rdb";
allow-update { key "dhcpdkey"; };
};
-----
Note the differences with trailing dots in the two files. Make sure that the named user identity can write to the database directory so it can maintain it's journal files and update the zone files. Also note that you can't just edit the zone files once updates are enabled.
Restart dhcpd and named, check the logs for errors and fix as required.
If your DNS service runs on a different machine then you will need to adjust the IP addresses and copy the security key over.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.