You are not logged in.

#1 2024-07-11 05:03:06

forward_one
Member
Registered: 2023-06-30
Posts: 32

systemd-networkd. config. route ( or switchboard )

I using systemd-networkd

I am trying to create a bridge between LAN (enp3s0 - DHCP Client) and wlan (wlan0 DHCP Server). I was able to create an AP. and everything works. but I couldn't set up the routing.

The DHCPserver does not show the ip of connected devices.

at the beginning, I would like to clarify a few definitions.
1) [Route] Gateway - must be specified only once in all configurations. this is where all packets will be sent by default.
2) [Route] Destination - setting up routing to a specific ip.
That is right?

problems:
DHCPServer does not display the IP addresses of connected devices. But I can ping them.

[Match]
Name=wlan0

[Network]
DHCPServer=yes
Address=192.168.123.1/24

well, the second problem is that I can't connect the networks. I even managed to use the bridge as a dhcp server and redirect packets from the wireless network. But I need this particular bridge and make it transparent.

Last edited by forward_one (2024-07-11 14:12:59)

Offline

#2 2024-07-13 08:55:49

Koatao
Member
Registered: 2018-08-30
Posts: 98

Re: systemd-networkd. config. route ( or switchboard )

Hi,

First, keep in mind systemd-networkd is only good to implement basic networking solutions. Although, most of time, it is enough (I use it myself for what you do too).
It might require you to manipulate the firewall (Netfilter) yourself to achieve what you want.

A bridge is a particular type of interface to kind of virtually "merge" two physical networks into one logical network: https://wiki.archlinux.org/title/Network_bridge.
This usually what a router does to seamlessly provide a single network for ethernet connected devices and wireless connected devices (WiFi).
If you only want to give access to others networks (like internet) to the AP clients, then you only need to forward traffic, you don't need to bridge.
Anyhow, could you, please, provide the configuration of your AP (usually a conf file) and the configuration of your network interfaces (the conf file of the systemd-networkd in /etc/system/network and the output of the "ip a" command).

As for your problems:
What do you mean about DHCPServer displaying anything? Because DHCPServer is just a directive in a configuration file, and a DHCP server only leases IP addresses, it does not know every IP addresses of every hosts in the network at any given moment. What are you trying to achieve with this list? What is your end goal?

Here a configuration file I use to set up a the host as a router and provide DHCP services to a network:

[Match]
Name=enp45s0

[Network]
Address=192.168.88.254
DHCPServer=true
IPMasquerade=true

[DHCPServer]
PoolOffset=1
PoolSize=1
EmitDNS=yes
DNS=1.1.1.1

Disclaimer, I have not use it in a while, it might be outdated. But it matches the wiki one: (https://wiki.archlinux.org/title/Systemd-networkd#[DHCPServer])

This sets up the interface enp45s0 with the IP address 192.168.88.254. It activates IP forwarding and IP Masquerading for this interface.
IP Forwarding is the basic router functionality, it routes packets not destined to the interface itself to other interface to be forwarded to other networks. (https://wiki.archlinux.org/title/Intern … d-networkd)
IP Masquerading is source NATing, it replaces the source IP address with the IP address of the interface sending out the forwarded packet.
Without the IP Masquerading directive, you need to do IP forwading and IP Masquerading manually yourself:
- https://wiki.archlinux.org/title/Intern … forwarding
- https://wiki.archlinux.org/title/Intern … Enable_NAT

As for the DHCPServer configuration, it is pretty straightforward and documented.

man systemd.network

If anything seems unclear to you, feel free to ask about it.

EDIT:
One last thing, compared to other DHCP Server, the one provided by systemd-networkd needs to have a matching rule in the firewall (if the firewall is set up to drop input packets not explicitly allowed).
To do so, you need to allow input packets on destination port UDP/67.

Last edited by Koatao (2024-07-13 09:04:27)

Offline

Board footer

Powered by FluxBB