Add possibility to edit router/gateway directly in the web page /cgi-bin/dhcp.cgi

Hi!

When I use keepalived and want DHCP to work, in theory I could in /var/ipfire/dhcp/dhcpd.conf use

include "/var/ipfire/dhcp/dhcpd.conf.local";

And then in dhcpd.conf.local have something like

subnet 192.168.222.0 netmask 255.255.255.0 #GREEN
{
        option routers 192.168.222.254;
} #GREEN

But if I do that DHCP hungs. So now have edited “option routers” in /var/ipfire/dhcp/dhcpd.conf instead.

See Keepalived & DHCP fail-over issues

We are able to edit most options from WEBGU, but not “option routers”, not even via “Additional DHCP options”.

Could we also have the option to edit “option routers” in WEBGUI?

1 Like

I have created two bug reports for this.

First one for “If I include “/var/ipfire/dhcp/dhcpd.conf.local” in /var/ipfire/dhcp/dhcpd.conf, DHCP stops working”:
https://bugzilla.ipfire.org/show_bug.cgi?id=12931

But I also think we should be able to edit the routers in WEBGUI, so I also created the bug report for “Add option to edit “option routers” in WEBGUI”
https://bugzilla.ipfire.org/show_bug.cgi?id=12930

1 Like

@forum

Revive this topic?
The last reply to this topic was about 1 year ago. Your reply will bump the topic to the top of its list and notify anyone previously involved in the conversation.
Are you sure you want to continue this old conversation?

yes it has to be resurrected :man_facepalming:

@raffe
nice find! so i do not have to bother anymore :+1:

reading:

Michael Tremer 2022-09-19 07:22:52 UTC
If you have any syntax errors in your custom configuration file, you will find any messages about that in /var/log/messages.

furthermore helps to summarize ipfire is not intended to realize this. :man_shrugging:

with:

And then in dhcpd.conf.local have something like
subnet 192.168.222.0 netmask 255.255.255.0 #GREEN
{
        option routers 192.168.222.254;
} #GREEN

still looking for dhcpd.conf.local syntax docs :mag_right:

the wiki:

To add specific options (e.g. change router ip, create dhcp entry) edit the file /var/ipfire/dhcp/dhcpd.conf.local.

https://wiki.ipfire.org/configuration/network/dhcp
is a dead end :construction:

so it is not possible to alter option routers on ipfire to me also like:
https://community.ipfire.org/t/how-can-i-point-dhcp-clients-to-other-gateway/5738
another dead end :construction:

The bug It is not open anymore, they closed it as they think I did a syntax error (I do not believe I did). (EDIT: THis is not true, see below:) So you have to create a new one if you want change. I still do it manually.

EDIT: The bug is closed as it works now, I just have not tested it. Bud Adolf did :+1:

I just added your exact block of statements from that bug into my dhcp.conf.local and pressed save on the dhcp page and dhcp restarted followed by unbound dhcp leases bridge and everything was running fine.

I also tried /etc/rc.d/init.d/dhcp restart and that also ended with dhcp running with no error messages in the logs.

I then just put
option routers 192.168.222.254
but without the ; at the end and then dhcp failsed to start and there were error messages in the log telling me that there was a missing semicolon somewhere.

Put the semicolon back and restarted dhcp and again it started with no problems.

I would suggest trying again with your block and running

tail -f /var/log/messages
in another terminal window so you can see what messages occur when you restart dhcp because for me it worked with no problem, even with a subnet definition totally different from the subnets I am running on my system.

4 Likes

Hooray, then it works now! :grinning: Nice, and thank you for testing Adolf! :heart: So many nice people here :heart_eyes:

I am glad I could help.

There must have been some syntax issue somehow or other because the dhcp code for dealing with dhcp.conf.local hasn’t been touched since I joined the community 5 years ago.

Give it a try and let us know that dhcp continues working for you as well.

2 Likes

You are probably right, the option routers 192.168.222.254; is quite straight forward and easy, but maybe I did something else wrong or messed it up somehow. Wouldn’t be the first time :rofl:

But so not my resent, what we now know, unnecessary posts here do not litter up this thread so that current users post gets hidden up there in the post above, please do not forget Add possibility to edit router/gateway directly in the web page /cgi-bin/dhcp.cgi - #3 by current_user

Hmm… Just to be clear, did you also in /var/ipfire/dhcp/dhcpd.conf add

include "/var/ipfire/dhcp/dhcpd.conf.local";

It is that last one that makes dhcpd to try to read dhcpd.conf.local and that was when I got problems.

One thing I have just found and tested out is the following.

After adding your statements into dhcp.conf.local if you run the following command

/usr/sbin/dhcpd -t -cf /var/ipfire/dhcp/dhcpd.conf

then if the lines in dhcp.conf.local are syntactically correct then you will get the following lines

Internet Systems Consortium DHCP Server 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit ISC DHCP - ISC
Config file: /var/ipfire/dhcp/dhcpd.conf
Database file: /var/state/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid

This was with your statement block in dhcp.conf.local

subnet 192.168.222.0 netmask 255.255.255.0 #GREEN
{
option routers 192.168.222.254;
} #GREEN

I then removed the ; just as a test and reran the dhcp -t test command from above and got the following response.

/usr/sbin/dhcpd -t -cf /var/ipfire/dhcp/dhcpd.conf
Internet Systems Consortium DHCP Server 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit ISC DHCP - ISC
/var/ipfire/dhcp/dhcpd.conf.local line 4: semicolon expected.
}
^
/var/ipfire/dhcp/dhcpd.conf.local line 4: unexpected end of file
} #GREEN
^
/var/ipfire/dhcp/dhcpd.conf line 90: /var/ipfire/dhcp/dhcpd.conf.local: bad parse.
include “/var/ipfire/dhcp/dhcpd.conf.local”
^
Configuration file errors encountered – exiting

If you think you have received this message due to a bug rather
than a configuration issue please read the section on submitting
bugs on either our web page at www.isc.org or in the README file
before submitting a bug. These pages explain the proper
process and the information we find helpful for debugging.

exiting.

So that test command is worth running after doing any changes in dhcp.conf.local to make sure no syntax errors have occurred.

I will add that info into the wiki.

The dhcp -t ... command can be run while dhcp is running and before restarting it to take the changed dhcp.conf.local statements.

4 Likes

That line is present by default at the end of the dhcp.conf file. You don’t have to add it yourself at all.

4 Likes

See:

1 Like

That commit was the adding of an extra column in the fixed leases table. Nothing to do with dhcp.conf or dhcp.conf.local.

It was also reverted before getting into a release anyway.

You can track that easier in the ipfire git repo rather than github.

I didn’t say there were no commits on dhcp, i did several myself over the last few years, just none changing the way dhcp.conf.local is used in dhcp.conf

Hey Adolf - was this comment for me? I am not sure I understand…


EDIT:
If it helps, what I posted was not a commit. It was the master/stable version. Should I not be posting this?

Then i got confused. I clicked on the link at the top and i ended up seeing a reverted commit at the top of the list. and i thought that was what you were showing.

Sorry for getting confused.

1 Like