[systemd-devel] systemd-network dhcp server gateway IP address issue

Dino Joseph Mycle dinomycle at gmail.com
Mon Jul 19 22:15:32 UTC 2021


Hello All,

I am trying to use the DHCP server coming with the systemd-networkd. I am
trying to set the Gateway IP address different from the eth0/server ip
address. but i am always getting in the dhcpclient the IP address of the
eth0/server IP .

Below is the network file

[Match]
Name=eth0


[Network]
Address=192.168.0.1/24
Gateway=192.168.0.2
DHCPServer=yes

[DHCPServer]
PoolOffset=112
PoolSize=16
EmitTimezone=false


looking at the source code
src/libsystemd-network/sd-dhcp-server.c

 if (server->emit_router) {

    r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0,
                            SD_DHCP_OPTION_ROUTER, 4, &server->address);
    if (r < 0)
        return r;
}

I see that it's appending SD_DHCP_OPTION_ROUTER with server->address, if my
above understanding is correct, Is the dhcp server only designed to
allocate gateway ip address same as the server IP address? or am I missing
some configuration or it's a bug we need to fix ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210719/cdb74b9a/attachment.htm>


More information about the systemd-devel mailing list