1

My following setup works perfectly fine if I set pc-eth1 as "Manual" connection, and if I give static IP addresses to my SBC (sbc-eth0 and sbc-eth1) and my pc-eth1:

enter image description here

With static values, I can ssh to both sbc-eth0 and sbc-eth1 from my pc-eth1.

Also, if I set pc-eth1 connection as "Shared" , and give IP address to pc-eth1 as "192.168.56.12" , sbc-eth0 also can get an IP address from my computer succesfully (In the range of 192.168.56.XXX). But in that case, NetworkManager GUI removes 2nd static IP address, and second interface of SBC ( sbc-eth1 ) does not get any IP address.

I read many similar questions in SO, and read the bugs related, but I couldn't understand why NetworkManager deletes 2nd IP address on pc-eth1 and don't serve 2nd IP range over it?

TL;DR:

I want NM to Serve DHCP over both IP addresses on pc-eth1.

Is there a way to achieve this?

1
  • Btw: Nothing stops you from running something on the side, e.g. in /etc/network/if-*.d/, to add another IP address, run a secondary DHCP server on it, etc. … Though your question seems to look like a case for a VLAN Commented Apr 23, 2023 at 11:04

1 Answer 1

1

With NetworkManager's shared mode, you can only setup one IPv4 range to be shared via DHCP.

Note that you can configure multiple IP addresses in the shared profile. If the GUI rejects that, it's a limitation of the GUI that you are using. Nmcli wouldn't prevent that. However, even if you do that, only the first IP address makes up the subnet to be shared. The second address won't determine a range that gets announced via DHCP.

I guess, you could drop an additional configuration file for dnsmasq to /etc/NetworkManager/dnsmasq-shared.d/. See for example https://fedoramagazine.org/internet-connection-sharing-networkmanager/

Alternatively, run your own DHCP server without NetworkManager, like dnsmasq.

But it's not clear to me how you expect sbc-eth0 and sbc-eth1 to get DHCP addresses from different subnets from the same DHCP server. It's drawn as if these would be two different interface. Do you mean to have two IP addresses on one interface? Otherwise you would at least need to configure the requesting interfaces in the DHCP server, to provide well known IP configuration based on who is asking. Again, dnsmasq has an option for that.

2
  • Awesome answer, many thanks. I will answer one by one: sbc-eth0 and sbc-eth1 have different mac addresses. So I need them to get IP address based on their MAC adress. But if I understand you correctly, this is not possible. Secondly, running dnsmasq without NetworkManager is a nice idea, but in this case how I will share internet access with sbc-ethX ? Commented Jul 10, 2020 at 13:16
  • NetworkManager has no direct API for configuring host-specific DHCP options with the shared mode. However, see --dhcp-host= option in man dnsmasq. If you use NetworkManager, inject that configuration in /etc/NetworkManager/dnsmasq-shared.d/ (see the link). If you don't use NetworkManager, you still would want to enable IPv4 NAT and IP forwarding additionally to running a DHCP server (which is what NetworkManager's shared mode does for you). This is done by adding a few simple iptables rules. Depending on whether you use iptables, nftables or firewalld, the answer is slightly different. Commented Jul 10, 2020 at 17:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.