diff --git a/docker/routlin-dash/app/action_networklayout.py b/docker/routlin-dash/app/action_networklayout.py index a7739e6..d1378f0 100644 --- a/docker/routlin-dash/app/action_networklayout.py +++ b/docker/routlin-dash/app/action_networklayout.py @@ -208,6 +208,20 @@ def networklayout_tablevlans_edit(): new_stored_gw = gateway_raw if (gateway_raw and gateway_raw != inferred_gw) else '' existing_gw = existing.get('dhcp_information', {}).get('explicit_overrides', {}).get('gateway', '') + dns_override = 'dns_server_override' in request.form + dns_raw = sanitize.ip(request.form.get('dns_server', '')) + if dns_override: + if not dns_raw: + flash('DNS server IP is required when override is enabled.', 'error') + return redirect(VIEW) + if dns_raw not in identity_ips: + flash(f"DNS server '{dns_raw}' must match one of the server identity IPs.", 'error') + return redirect(VIEW) + inferred_dns = (min(identity_ips, key=lambda ip: int(ip.split('.')[-1])) + if identity_ips else '') + new_stored_dns = dns_raw if (dns_override and dns_raw and dns_raw != inferred_dns) else '' + existing_dns = existing.get('dhcp_information', {}).get('explicit_overrides', {}).get('dns_server', '') + _ids_unchanged = ( len(new_identities) == len(old_identities) and all( @@ -225,7 +239,8 @@ def networklayout_tablevlans_edit(): and mdns_reflection == bool(existing.get('mdns_reflection', False)) and sorted(use_blocklists) == sorted(existing.get('use_blocklists', [])) and _ids_unchanged - and new_stored_gw == existing_gw): + and new_stored_gw == existing_gw + and new_stored_dns == existing_dns): flash('No changes were made.', 'info') return redirect(VIEW) @@ -246,6 +261,10 @@ def networklayout_tablevlans_edit(): dhcp_overrides['gateway'] = new_stored_gw else: dhcp_overrides.pop('gateway', None) + if new_stored_dns: + dhcp_overrides['dns_server'] = new_stored_dns + else: + dhcp_overrides.pop('dns_server', None) errors = validate.validate_config(cfg) if errors: for msg in errors: diff --git a/docker/routlin-dash/app/view_page.py b/docker/routlin-dash/app/view_page.py index 103835b..d1e510a 100644 --- a/docker/routlin-dash/app/view_page.py +++ b/docker/routlin-dash/app/view_page.py @@ -325,6 +325,9 @@ def _config_datasource(name): row['server_identity_gateway'] = ( v.get('dhcp_information', {}).get('explicit_overrides', {}).get('gateway', '') ) + row['server_identity_dns_server'] = ( + v.get('dhcp_information', {}).get('explicit_overrides', {}).get('dns_server', '') + ) rows.append(row) return rows diff --git a/docker/routlin-dash/data/page_content.json b/docker/routlin-dash/data/page_content.json index dd41e69..22de853 100644 --- a/docker/routlin-dash/data/page_content.json +++ b/docker/routlin-dash/data/page_content.json @@ -1588,7 +1588,8 @@ "pair_col2": "server_identity_hostnames", "pair_label2": "Hostname (Opt)", "pair_validate2": "networkname", - "gateway_col": "server_identity_gateway" + "gateway_col": "server_identity_gateway", + "dns_col": "server_identity_dns_server" }, { "col": "radius_default",