LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-06-2024, 04:55 AM   #1
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Using NetworkManager "Shared to Other Computers" - how to skip some static IP addresses?


My situation:

I want to replace my complex hard to set up router at 192.168.1.1 with a simpler computer using NetworkManager "Shared to Other Computers".

For most dhcp client machines, it's okay for them to have dynamically assigned IP addresses from, say, 192.168.1.2 to 192.168.1.255

HOWEVER, I have a file server which must use the IP address 192.168.1.32.

My problem:

I do NOT want NetworkManager to assign 192.168.1.32 to some dhcp client. I'd like to accomplish this by, say, restricting the range of dynamically assigned IP addresses to, say, 192.168.1.128 ... 192.168.1.255. The precise range is not important to me. I just need it to skip 192.168.1.32

My questions:

1) Am I worrying for nothing? Is NetworkManager or dnsmasq smart enough to know there's already an active 192.168.1.32 out there and to skip it?

2) Could I maybe do a simple hack like putting an option file in /etc/NetworkManager/dnsmasq-shared.d defining an "option" of an NTP server with address 192.168.1.32? Is dnsmasq smart/dumb enough to avoid dynamic assignment to an IP address specified in a server option?

3) Is there some place with a list of DHCP clients, where I could add a fake entry for 192.168.1.32?

4) Is there some other solution I'm missing?

Thanks!
 
Old 01-06-2024, 08:57 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,716

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
1. No, No, as far as I know.

2&3&4. As far as I know you can add a configuration file with desired settings in /etc/NetworkManager/dnsmasq.d

dhcp-range=192.168.1.100,192.168.1.250,12h (sets range for DHCP and lease time)
In a /24 network valid IP address range is x.x.x.1 - x.x.x.254

You can set a DHCP static IP address sometimes known as address reservation too but must be outside the DHCP range.

dhcp-host=d0:50:99:82:e7:2b,192.168.1.xxx (change MAC to match server)

Other options for setting DNS etc can by found with various howto guides.

You could turn off DHCP on your router and run dnsmasq from the same computer versus "shared to other computer". Maybe a little more complicated depending on distribution and systemd-resolved and figuring out all the settings.
 
1 members found this post helpful.
Old 01-06-2024, 11:09 AM   #3
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546

Original Poster
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by michaelk View Post
2&3&4. As far as I know you can add a configuration file with desired settings in /etc/NetworkManager/dnsmasq.d

dhcp-range=192.168.1.100,192.168.1.250,12h (sets range for DHCP and lease time)
In a /24 network valid IP address range is x.x.x.1 - x.x.x.254

You can set a DHCP static IP address sometimes known as address reservation too but must be outside the DHCP range.

dhcp-host=d0:50:99:82:e7:2b,192.168.1.xxx (change MAC to match server)
Thanks so much! Thanks to your info, I have made a lot of progress, although not actually solving my problem yet.

First off, I figured out that in Debian 12, I need to create this config file in /etc/NetworkManager/dnsmasq-shared.d rather than dnsmasq.d

I based this on the command that is being run by NetworkManager:

Code:
$ ps -ef | grep dns
nobody      4525     686  0 10:37 ?        00:00:00 /usr/sbin/dnsmasq --conf-file=/dev/null --no-hosts --keep-in-foreground --bind-interfaces --except-interface=lo --clear-on-reload --strict-order --listen-address=192.168.7.1 --dhcp-range=192.168.7.10,192.168.7.254,60m --dhcp-leasefile=/var/lib/NetworkManager/dnsmasq-enp4s2.leases --pid-file=/run/nm-dnsmasq-enp4s2.pid --conf-dir=/etc/NetworkManager/dnsmasq-shared.d
kuo         4980    1873  0 10:39 pts/2    00:00:00 grep dns
(I'm testing on a little sub-network so that's why the IP addresses are different from what was specified at top.)

So here's my problem ... this command includes --dhcp-range, and this overrides whatever dhcp-range I specify in my config file.

My config file looks like this:
Code:
 dhcp-range=192.168.7.222,192.168.7.225,12h

#dhcp-host=d0:50:99:82:e7:2b,192.168.7.32
#dhcp-host=00:1a:a0:e4:63:a3,192.168.7.19
So far, I've experimented with setting reserved IP addresses with dhcp-host (currently commented out), and it actually does "succeed" even when the specified IP address is within the dhcp-range. By "succeed", I mean that I get no errors or complaints, and this IP address is indeed served up to the client even though this IP address is within the dhcp-range.

HOWEVER ...

Maybe my problem is actually solved?

If I alter my conf file, and then look at the list of dhcp clients, I see this:

Code:
root@cinderella:~# cat /etc/NetworkManager/dnsmasq-shared.d/IJKdns.conf 

#dhcp-range=192.168.7.232,192.168.7.235,12h
 dhcp-host=00:1a:a0:e4:63:a3,192.168.7.77

root@cinderella:~# cat /var/lib/NetworkManager/dnsmasq-enp4s2.leases

1704563803 00:1a:a0:e4:63:a3 192.168.7.77 mulan ff:a0:e4:63:a3:00:01:00:01:26:87:1a:46:00:1a:a0:ad:63:66
In other words:

1) I did NOT alter the dhcp-range, which seems hard specified to 192.168.7.10,192.168.7.254,60m.

2) I did specify a dhcp-host to 192.168.7.77, within that dhcp-range

3) NetworkManager didn't complain, and served up 192.168.7.77 to the client

4) This did create an entry in dnsmasq-enp4s2.leases

So, I think that the entry in dnsmasq-enp4s2.leases means that the DHCP server will NOT accidentally assign a different client its IP address.

I'm going to mark this problem as solved, unless my understanding turns out to be incorrect.

For now, I think my solution is:

1) On my replacement router machine, just use NetworkManager to manage all my network connections and stuff (I'm handling network security separately ... beyond the scope of this issue)

2) Set the internal network wired connection to "Shared to Other Computers", with 192.168.1.1/24/192.168.1.1.

3) Create /etc/NetworkManager/dnsmasq-shared.d/IJKdns.conf looking something like this:
Code:
dhcp-host=00:1a:a0:e4:63:a3,192.168.1.32
And I think that does it! The dhcp-range will by 192.168.1.10 to 192.168.1.254 and there may be nothing I can do about that. But I think it will avoid serving up 192.168.1.32 to any other clients, so that'll be okay.

As it is, there are actually a lot of other computers which I'd like to specify the IP address on, so that'll be nice and easy for me to configure as well.

All in all, this is MUCH simpler for me to install, set up, and manage than my current router. It's a mess of IP chains and stuff.
 
Old 01-06-2024, 11:53 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,716

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
Actually I don't think it matters with dnsmasq if the static mapping is in the range. I usually don't since not all dhcp servers allow it.
 
1 members found this post helpful.
Old 01-08-2024, 08:33 PM   #5
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546

Original Poster
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
BTW, I've replaced my router computer with this, and it seems to be working great. Thanks so much!

Not everything I expect shows up in /var/lib/NetworkManager/dnsmasq-enp0s25.leases though ... so there's still some potential conflict with DHCP assigning a client an IP address that collides with one that's already in use or reserved. So I'm still not entirely sure.
 
  


Reply

Tags
dhcp server, dnsmasq, networkmanager



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
[SOLVED] Network-manager-applet "Shared to other computers" question taylorkh Linux - Networking 3 09-30-2017 06:41 PM
other computers on networks with windows, see other computers knightnet Linux - Newbie 3 03-28-2017 02:56 PM
how to skip NetworkManager in kickstart ? vdx Fedora 1 03-21-2009 10:35 AM
Howto Assign Multiple Static Public IP Addresses under SBC's PPPoE Static Ip system o trekgraham Linux - Networking 8 04-17-2007 10:51 AM
LAN with static IP addresses and shared internet connection Klas Mandriva 1 01-21-2004 07:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:43 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