LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-18-2018, 03:33 AM   #1
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 666

Rep: Reputation: Disabled
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:

Code:
dhcp-host=!MAC,IP
Is this possible to do?
 
Old 03-18-2018, 04:44 AM   #2
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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.
 
1 members found this post helpful.
Old 03-18-2018, 05:32 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
If you are using dnsmasq for local DNS the hostname should automatically resolve to the correct IP address. Just ssh using hostname.

When the laptops are connected you can find their MACS but assigning if not would mean multiple computers could have the same IP address.
 
Old 03-18-2018, 07:01 AM   #4
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 666

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by allend View Post
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?
 
Old 03-18-2018, 07:03 AM   #5
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 666

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
If you are using dnsmasq for local DNS the hostname should automatically resolve to the correct IP address. Just ssh using hostname.
I'm not using DNS at all.

Quote:
Originally Posted by michaelk View Post
When the laptops are connected you can find their MACS
I know, I can also find the IP they get from dnsmasq by physically logging into them, but that's exactly the step I'm trying to skip.
 
Old 03-18-2018, 07:39 AM   #6
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Quote:
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?
Not the behaviour I have observed using dnsmasq.
 
Old 03-18-2018, 07:43 AM   #7
MisterL
LQ Newbie
 
Registered: Mar 2018
Location: Germany
Distribution: Slackware
Posts: 22

Rep: Reputation: 10
Quote:
Originally Posted by FlinchX View Post
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.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I find what MAC address web pages see as my MAC address rob.rice General 20 05-29-2010 02:08 AM
API for mapping Physical Address to Virtual Address Lakshman_smt Linux - Software 2 10-15-2006 09:08 PM
Memory Mapping (same physical address = virtual address) skd.tech Linux - Kernel 7 07-24-2006 11:13 PM
mapping custom keys TomalakBORG Linux - General 8 04-24-2005 03:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration