How do I start a DHCP server in VyOS?

I am running VyOS as a live disk with 2 physical ethernet interfaces. The first network interface hosts a 10.151.X.X subnet. This network interface is used for SSHing into VyOS. This IP is statically assigned.
The second network interface hosts a 192.168.0.1/16 subnet. This is the network interface that needs to supply IP addresses via DHCP to other clients on the network. I have the physical DHCP network interface connected to an 8-port unmanaged network switch. This network interface is also statically assigned.
The unmanaged network switch is connected to 2 ubuntu linux clients. Currently, neither DHCP client is receiving an IP address from the DHCP server. I checked the client systems and none of them are receiving an IP address from the DHCP server.
I am able to, however, assign a static IP to the 2 clients to get the clients manually (using sudo ip addr add ip/netmask dev device) to ping each other and the VyOS static IP 192.168.1.2/16. This makes me think that the hardware is not a problem.

What do I have to do to get the DHCP address assignment to work? At some point I would like to have both static and DHCP IP leases, but I figure I should get DHCP working first.

This is the version of my VyOS instance:

vyos@vyos:~$ show version
Version:          VyOS 1.4-rolling-202306130317
Release train:    current

Built by:         [email protected]
Built on:         Tue 13 Jun 2023 03:17 UTC
Build UUID:       52285921-0a5b-4adf-bdd4-0b20e155a3eb
Build commit ID:  dd194c6e8024e1

Architecture:     x86_64
Boot via:         livecd
System type:      bare metal

Hardware vendor:  Intel(R) Client Systems
Hardware model:   NUC11PAHi7
Hardware S/N:     G6PA1460005P
Hardware UUID:    c6ae2862-8f53-b191-ee6a-1c697aadd567

Copyright:        VyOS maintainers and contributors

This is what my configuration looks like:

vyos@vyos:~$ show configuration json pretty
{
    "interfaces": {
        "ethernet": {
            "eth0": {
                "address": [
                    "192.168.1.2/16"
                ],
                "hw-id": "98:fc:84:ee:bf:34"
            },
            "eth1": {
                "address": [
                    "10.151.201.76/20"
                ],
                "hw-id": "1c:69:7a:ad:d5:67"
            }
        },
        "loopback": {
            "lo": {}
        },
        "wireless": {
            "wlan0": {
                "hw-id": "60:e3:2b:35:12:31",
                "physical-device": "phy0"
            }
        }
    },
    "protocols": {
        "static": {
            "route": {
                "0.0.0.0/0": {
                    "next-hop": {
                        "10.151.192.1": {}
                    }
                }
            }
        }
    },
    "service": {
        "dhcp-server": {
            "shared-network-name": {
                "TESTLAN": {
                    "authoritative": {},
                    "subnet": {
                        "192.168.0.0/16": {
                            "default-router": "192.168.0.1",
                            "domain-name": "vyos.net",
                            "lease": "600",
                            "name-server": [
                                "192.168.0.1"
                            ],
                            "range": {
                                "0": {
                                    "start": "192.168.0.9",
                                    "stop": "192.168.0.254"
                                }
                            }
                        }
                    }
                }
            }
        },
        "https": {
            "api": {
                "debug": {},
                "keys": {
                    "id": {
                        "theid": {
                            "key": "thepass"
                        }
                    }
                }
            }
        },
        "ntp": {
            "allow-client": {
                "address": [
                    "0.0.0.0/0",
                    "::/0"
                ]
            },
            "server": {
                "time1.vyos.net": {},
                "time2.vyos.net": {},
                "time3.vyos.net": {}
            }
        },
        "ssh": {
            "port": [
                "22"
            ]
        }
    },
    "system": {
        "config-management": {
            "commit-revisions": "100"
        },
        "conntrack": {
            "modules": {
                "ftp": {},
                "h323": {},
                "nfs": {},
                "pptp": {},
                "sip": {},
                "sqlnet": {},
                "tftp": {}
            }
        },
        "console": {
            "device": {
                "ttyS0": {
                    "speed": "115200"
                }
            }
        },
        "host-name": "vyos",
        "login": {
            "user": {
                "vyos": {
                    "authentication": {
                        "encrypted-password": "$6$QxPS.uk6mfo$9QBSo8u1FkH16gMyAVhus6fU3LOzvLR9Z9.82m3tiHFAxTtIkhaZSWssSgzt4v4dGAL8rhVQxTg0oAG9/q11h/",
                        "plaintext-password": ""
                    }
                }
            }
        },
        "syslog": {
            "global": {
                "facility": {
                    "all": {
                        "level": "info"
                    },
                    "local7": {
                        "level": "debug"
                    }
                }
            }
        }
    }
}

Hi!

To investigate this issue, you can first check the DHCP logs by using the command below. You should then be able to see the corresponding output and check whether DHCP is functioning properly or not.

show log dhcp server

Sample output:

Jun 14 22:38:34 dhcpd[3605]: DHCPDISCOVER from 00:50:79:66:68:00 (PC1) via eth0
Jun 14 22:38:34 dhcpd[3605]: DHCPOFFER on 192.168.0.9 to 00:50:79:66:68:00 (PC1) via eth0
Jun 14 22:38:35 dhcpd[3605]: DHCPREQUEST for 192.168.0.9 (192.168.0.1) from 00:50:79:66:68:00 (PC1) via eth0
Jun 14 22:38:35 dhcpd[3605]: DHCPACK on 192.168.0.9 to 00:50:79:66:68:00 (PC1) via eth0
Jun 14 22:38:54 dhcpd[3605]: DHCPDISCOVER from 00:50:79:66:68:01 (PC2) via eth0
Jun 14 22:38:54 dhcpd[3605]: DHCPOFFER on 192.168.0.10 to 00:50:79:66:68:01 (PC2) via eth0
Jun 14 22:38:55 dhcpd[3605]: DHCPREQUEST for 192.168.0.10 (192.168.0.1) from 00:50:79:66:68:01 (PC2) via eth0
Jun 14 22:38:55 dhcpd[3605]: DHCPACK on 192.168.0.10 to 00:50:79:66:68:01 (PC2) via eth0

Thanks!

I ran the above command and I see this output:

Jun 14 18:01:23 sh[8752]: touch: cannot touch '/config/dhcpd.leases': No such file or directory
Jun 14 18:01:23 systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Jun 14 18:01:23 systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Jun 14 18:01:23 systemd[1]: Failed to start isc-dhcp-server.service - ISC DHCP IPv4 server.
Jun 14 18:01:23 systemd[1]: isc-dhcp-server.service: Scheduled restart job, restart counter is at 3.
Jun 14 18:01:23 systemd[1]: Stopped isc-dhcp-server.service - ISC DHCP IPv4 server.
Jun 14 18:01:23 systemd[1]: Starting isc-dhcp-server.service - ISC DHCP IPv4 server...
Jun 14 18:01:23 sh[8756]: touch: cannot touch '/config/dhcpd.leases': No such file or directory
Jun 14 18:01:23 systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Jun 14 18:01:23 systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Jun 14 18:01:23 systemd[1]: Failed to start isc-dhcp-server.service - ISC DHCP IPv4 server.
Jun 14 18:01:23 systemd[1]: isc-dhcp-server.service: Scheduled restart job, restart counter is at 4.
Jun 14 18:01:23 systemd[1]: Stopped isc-dhcp-server.service - ISC DHCP IPv4 server.
Jun 14 18:01:23 systemd[1]: Starting isc-dhcp-server.service - ISC DHCP IPv4 server...
Jun 14 18:01:23 sh[8758]: touch: cannot touch '/config/dhcpd.leases': No such file or directory

This tells me I need to create that leases file. Is that a manually created file or an auto-generated file from another VyOS software package or process? Do I need to give the vyos user the permissions to write to that location on the filesystem? Are the permissions missing because this is a live disk? I thought a DHCP server would figure out what is on a network, assign an IP, and then write the IP lease to a file. I am sure I am missing something.

I remember running into a similar error earlier, but I thought nothing of it…

You are in livecd
You have to install system image

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.