Set a different DHCP Range than the Router IP

Hello,

I would like my router and other network devices such as servers to have a static IP in the following area.

10.0.0.X (The router has 10.0.0.1)

The DHCP range should start at 10.0.1.100 and stop at 10.0.1.150.

At the moment I solve it like this.

config dhcp 'lan'
        option interface 'lan'
        option leasetime '12h'
        option start '10.0.1.100'
        option limit '150'
        option dhcpv6 'server'
        option ra 'server'
        option ra_management '1'
        list dhcp_option '6,10.0.0.2'

But then I get errors in the web interface.
Is there a better configuration for my case?

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#static_leases


which web interface and what errors?

I can give the Static IP on client side. Thats OK.

But I want the DHCP range to start at 10.0.1.XXX and not 10.0.0.1 because that’s the router IP.

I think the error comes because of this change

option start ‘10.0.1.100’

option start should just be 100. But how can i set the range?

The error is on Foris

## Remote Exception: Internal error invalid literal for int() with base 10: '10.0.1.100'('<class 'ValueError'>')

{"module": "lan", "action": "get_settings", "kind": "request"}

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/foris_controller/message_router.py", line 114, in process_message
    data = module_instance.perform_action(message["action"], message.get("data", {}))
  File "/usr/lib/python3.6/site-packages/foris_controller/module_base.py", line 60, in perform_action
    res = action_function(data)
  File "/usr/lib/python3.6/site-packages/foris_controller_modules/lan/__init__.py", line 36, in action_get_settings
    return self.handler.get_settings()
  File "/usr/lib/python3.6/site-packages/foris_controller/utils.py", line 110, in inner
    res = func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/foris_controller_modules/lan/handlers/openwrt.py", line 41, in get_settings
    return self.uci.get_settings()
  File "/usr/lib/python3.6/site-packages/foris_controller_backends/lan/__init__.py", line 104, in get_settings
    dhcp_data, "dhcp", "lan", "start", self.DEFAULT_DHCP_START))
ValueError: invalid literal for int() with base 10: '10.0.1.100'


{'CONTENT_LENGTH': '0',
 'DOCUMENT_ROOT': '/www',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'foris.session=12dda7a071032916ca7d02f5aa2f6a3e; '
                'foris.ws.session=cb8c2a19737736a9a68c8654e38eacca',
 'HTTP_HOST': '10.0.0.1',
 'HTTP_REFERER': 'http://10.0.0.1/foris/config/main/notifications/',
 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                    'AppleWebKit/537.36 (KHTML, like Gecko) '
                    'Chrome/72.0.3626.119 Safari/537.36',
 'PATH_INFO': '/main/lan/',
 'PATH_TRANSLATED': '/www/main/lan/',
 'QUERY_STRING': '',
 'REDIRECT_STATUS': '200',
 'REMOTE_ADDR': '10.0.1.138',
 'REMOTE_PORT': '57262',
 'REQUEST_METHOD': 'GET',
 'REQUEST_SCHEME': 'http',
 'REQUEST_URI': '/foris/config/main/lan/',
 'SCRIPT_FILENAME': '/www/foris/config',
 'SCRIPT_NAME': '/foris/config',
 'SERVER_ADDR': '10.0.0.1',
 'SERVER_NAME': '10.0.0.1',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'lighttpd/1.4.50',
 'bottle.app': <bottle.Bottle object at 0x2c4b870>,
 'bottle.raw_path': '/lan/',
 'bottle.request': <LocalRequest: GET http://10.0.0.1/foris/config/main/lan/>,
 'bottle.request.urlparts': SplitResult(scheme='http', netloc='10.0.0.1', path='/foris/config/main/lan/', query='', fragment=''),
 'bottle.route': <GET '/<page_name:re:.+>/' <function config_page_get at 0x2c47cf0>>,
 'foris.backend': UbusSender('/var/run/ubus.sock'),
 'foris.language': 'de',
 'foris.session': <foris.middleware.sessions.SessionForisProxy object at 0x2e07410>,
 'foris.session.data': {'csrf_token': 'juR4kxOeNNvHnUE317QOnbmPi02WPsJo',
                        'user_authenticated': True},
 'foris.session.id': '12dda7a071032916ca7d02f5aa2f6a3e',
 'foris.version': '99.1',
 'route.handle': <GET '/<page_name:re:.+>/' <function config_page_get at 0x2c47cf0>>,
 'route.url_args': {'page_name': 'lan'},
 'wsgi.errors': <flup.server.fcgi_base.OutputStream object at 0x2e04db0>,
 'wsgi.input': <flup.server.fcgi_base.InputStream object at 0x2db7970>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': True,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}

Might be just a bug in Foris

but not actually impeding the actual DHCP functionality. You mentioned initially

and thus it would imply that DHCP is working as expected except for that Foris issue. Any issue with LuCI?

LuCI workd fine. There’s no errors.

I believe you want:

option start '100'
option limit '150'

I got that via Foris, though for a little different range and I use a 192.168.x prefix. Generally to minimize problems, I’d suggest to use Foris to set things that can be set in there. When there are multiple configuration layers, I understand it’s quite difficult to support changing stuff on arbitrary layers and propagate meaningfully to others.

I want a DHCP Range from

10.0.1.100 - 10.0.1.150 and a Router IP with 10.0.0.1

And this without errors in Foris.

I see, I didn’t notice this mismatch. I suppose Foris isn’t designed for more than /24 for LAN. I can’t see why you don’t make Omnia’s LAN 10.0.1.1, but I guess you have some reasons…

It’s an optical thing for me.
That’s where the autist in me comes out.

But maybe I go then to 10.0.1.1

In that case I can’t see an argument against DHCP assigning from within 10.0.0.x :slight_smile:

Of course, none of this claims Foris can’t be improved to handle these… it’s just that I’m convinced the Turris team’s priorities are currently elsewhere (and I agree with that).

Hello,
was this issue reported somewhere? I couldn’t find any mention of it on https://gitlab.nic.cz/groups/turris/foris/-/issues
I understand that this problem is not critical and does not affect all users but I think it should be fixed anyway. It is not necessary to extend the functionality of Foris to support more complex IP ranges (even though it would be perfect). But Foris should at least display a message that a more complex configuration was set in LuCI instead of giving up and reporting an internal error.

I haven´t any problem with 10.0.0.0/8 block and Foris.

This issue is not within re/Foris. Let’s say we are somehow strict about what can be configured with re/Foris as we allow only valid values. On the other hand, LuCI neither in SSH, because there isn’t any check if you configured it correctly. You will notice that if you will restart the service. If it does not start, you need to check logs, and if starts, you need to check if there are not any warnings.

You can check it with documentation of OpenWrt for DHCP [1] that the only valid value for start is an integer. It means that should be e.g. 100 as you correctly pointed out. There shouldn’t be an IP address.

Regarding the issue that Foris crashes on it, we know that it does what it does, which is not good for the user experience and we improved the behavior in reForis.

[1] https://openwrt.org/docs/guide-user/base-system/dhcp

Sorry, it was my fault. I configured LuCI incorrectly which caused an error in Foris. The problem was that I filled in a complete IP as a “DHCP Start” instead of just a number.