[SOLVED] dnsmasq question: custom mapping of IP address to MAC
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
dnsmasq question: custom mapping of IP address to MAC
I have Slackware64-14.2 with dnsmasq-2.78-x86_64-1_slack14.2 and the following setup:
- 2 Ethernet interfaces: one looks to the real world (EXTERNAL), the other is plugged into a switch (INTERNAL), ip forwarding, NAT
- I run dnsmasq on INTERNAL to provide a DHCP service for the local network
- there's a second desktop that is always plugged into the switch and always gets the same IP address from dnsmasq. I did this with a
Code:
dhcp-host=MAC,IP
line in /etc/dnsmasq.conf
- I also often need to plug different laptops (which I do not own) into the switch and get them connected to the local network after dnsmasq assigns them an IP
Now my goal is to have dnsmasq always assign those different laptops the same IP, just so I could skip the step of looking what IP they got and could immediately ssh into them. How can I do this?
I've been reading the examples in dnsmasq.conf as well as the man page but with no success. Basically I need to tell dnsmasq "assign this fixed IP to any computer which has a network card with a MAC address that is NOT xx:xx:xx:xx:xx:xx". But I did not find anything like:
The way I handle this (for my 192.168.4 address space) is to have the fixed hosts assigned addresses from 192.158.4.2 to 192.168.4.39. Then I have a 'dhcp-range=192.168.4.40,192.168.4.62,12h', so that additional hosts will get an address in that range. If you are always only adding one additional laptop, it will get the 192.168.4.40 address.
The way I handle this (for my 192.168.4 address space) is to have the fixed hosts assigned addresses from 192.158.4.2 to 192.168.4.39. Then I have a 'dhcp-range=192.168.4.40,192.168.4.62,12h', so that additional hosts will get an address in that range. If you are always only adding one additional laptop, it will get the 192.168.4.40 address.
Interesting, can I have a 'dhcp-range=192.168.4.40,192.168.4.40'? Yes, it's always just one laptop (but not always the same), but doesn't having an IP range imply that IP addresses get assigned randomly?
Interesting, can I have a 'dhcp-range=192.168.4.40,192.168.4.40'? Yes, it's always just one laptop (but not always the same), but doesn't having an IP range imply that IP addresses get assigned randomly?
Hi,
I'm not using dnsmasq, but generally it should be allowd to have an DHCP-Scope with only one address. If it doesn't just allow 2 IPs in that range and give the other one to "2nd desktop" you've mentioned in your first post.
But the problem is if the laptop doesn't release the Adress, ie. if it crashes.
Then the DHCP-scope is full and a newly connected laptop won't get any IP since it's still assigned to another MAC address. Before reducing DHCP Lease Time be aware, that clients may ask the server for keeping the leased address when 50% of the lease duration is expired.
But why even bother? Just take a look into the arp table of the computer you're using for ssh-client. As long as its in the same logical network (192.168.4.x probably), the "arp" command will list the local devices.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.