Thx for this patch. It resolves a problem, which shows up from time to time. It allows some freedom in defining fixed leases ( without interpretation of sense ), but marks this exception of the 'IPFire philosophy'. Bernhard Reviewed-by: Bernhard Bitsch Am 13.02.2023 um 18:55 schrieb Adolf Belka: > - This patch marks all IP's that are in the Fixed list but are also in the dynamic range > that has been defined, in red. > - Additional function created to check if an ip address is in a defined range. > - Added an additional key item under the Fixed Leases table for Fixed IP in dynamic range > - Added line to English Language file for this key item. > - ./make lang run before commit. > - Tested in vm testbed and confirmed that any ip address in the Fixed Leases table that > is in the defined dynamic range is highlighted in red > - This uses the css background-color appoach from the first patch in this set. > - This patch only highlights those IP's that overlap in red but does nothing more. So a > user can still create new ones if they want but they will all show up in red. > - I may come back at a later time with a further patch that allows IP's that overlap but > are in the existing leases file to continue being used and edited but prevents new IP's > that overlap from being created. > - This patch flags up if people are doing things that they shouldn't be doing but allows > them to continue doing so without changing anything if they don't want to. > > Tested-by: Adolf Belka > Signed-off-by: Adolf Belka > --- > config/cfgroot/network-functions.pl | 24 +++++++++++++++++++++++ > doc/language_issues.de | 2 +- > doc/language_issues.en | 2 +- > doc/language_issues.es | 2 ++ > doc/language_issues.fr | 15 ++++++--------- > doc/language_issues.it | 2 +- > doc/language_issues.nl | 2 +- > doc/language_issues.pl | 2 +- > doc/language_issues.ru | 2 +- > doc/language_issues.tr | 2 +- > doc/language_missings | 15 ++++++++------- > html/cgi-bin/dhcp.cgi | 30 ++++++++++++++++++++++------- > langs/en/cgi-bin/en.pl | 1 + > 13 files changed, 71 insertions(+), 30 deletions(-) > > diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl > index 4ac6d8670..7b38cfac7 100644 > --- a/config/cfgroot/network-functions.pl > +++ b/config/cfgroot/network-functions.pl > @@ -307,6 +307,24 @@ sub ip_address_in_network($$) { > return (($address_bin >= $network_bin) && ($address_bin <= $broadcast_bin)); > } > > +# Returns True if $ipaddress is within $ipstart and $ipend range. > +sub ip_address_in_range($$) { > + my $ipaddress = shift; > + my $ipstart = shift; > + my $ipend = shift; > + > + my $ipaddress_bin = &ip2bin($ipaddress); > + return undef unless (defined $ipaddress_bin); > + > + my $ipstart_bin = &ip2bin($ipstart); > + return undef unless (defined $ipstart_bin); > + > + my $ipend_bin = &ip2bin($ipend); > + return undef unless (defined $ipend_bin); > + > + return (($ipaddress_bin >= $ipstart_bin) && ($ipaddress_bin <= $ipend_bin)); > +} > + > sub setup_upstream_proxy() { > my %proxysettings = (); > &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); > @@ -666,6 +684,12 @@ sub testsuite() { > $result = &ip_address_in_network("192.168.30.11", "0.0.0.0/8"); > assert('ip_address_in_network("192.168.30.11", "0.0.0.0/8")', !$result); > > + $result = &ip_address_in_range("192.168.30.11", "192.168.30.10", "192.168.30.20"); > + assert('ip_address_in_range("192.168.30.11", "192.168.30.10", "192.168.30.20")', $result); > + > + $result = &ip_address_in_range("192.168.30.21", "192.168.30.10", "192.168.30.20"); > + assert('ip_address_in_range("192.168.30.21", "192.168.30.10", "192.168.30.20")', !$result); > + > print "Testsuite completed successfully!\n"; > > return 0; > diff --git a/doc/language_issues.de b/doc/language_issues.de > index 88c7879be..392416192 100644 > --- a/doc/language_issues.de > +++ b/doc/language_issues.de > @@ -883,7 +883,7 @@ WARNING: untranslated string: cake profile pppoe-ptm 27 = PPPoE PTM (27 bytes) > WARNING: untranslated string: cake profile pppoe-vcmux 32 = PPPoE VC-MUX (32 bytes) > WARNING: untranslated string: cake profile raw 0 = Raw (no overhead compensation) > WARNING: untranslated string: desired = Desired > -WARNING: untranslated string: dh parameter = unknown string > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: disable = Disable > WARNING: untranslated string: download apple profile = Download Apple Configuration Profile > WARNING: untranslated string: enable = Enable > diff --git a/doc/language_issues.en b/doc/language_issues.en > index c29e3bed6..08fda35b7 100644 > --- a/doc/language_issues.en > +++ b/doc/language_issues.en > @@ -574,7 +574,6 @@ WARNING: untranslated string: details = Details > WARNING: untranslated string: device = Device > WARNING: untranslated string: devices on blue = Devices on BLUE > WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > WARNING: untranslated string: dhcp advopt add = Add a DHCP option > WARNING: untranslated string: dhcp advopt added = DHCP option added > WARNING: untranslated string: dhcp advopt blank value = DHCP Option value cannot be empty. > @@ -601,6 +600,7 @@ WARNING: untranslated string: dhcp dns key name = Key Name > WARNING: untranslated string: dhcp dns update = DNS Update > WARNING: untranslated string: dhcp dns update algo = Algorithm > WARNING: untranslated string: dhcp dns update secret = Secret > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dhcp make fixed lease = Add to fix leases > WARNING: untranslated string: dhcp server = DHCP Server > WARNING: untranslated string: dhcp server disabled = DHCP server disabled. Stopped. > diff --git a/doc/language_issues.es b/doc/language_issues.es > index 0bd390d5d..ffe423bd1 100644 > --- a/doc/language_issues.es > +++ b/doc/language_issues.es > @@ -228,6 +228,7 @@ WARNING: translation string unused: dh key move failed > WARNING: translation string unused: dh key warn > WARNING: translation string unused: dh key warn1 > WARNING: translation string unused: dh name is invalid > +WARNING: translation string unused: dh parameter > WARNING: translation string unused: dhcp base ip fixed lease > WARNING: translation string unused: dhcp create fixed leases > WARNING: translation string unused: dhcp fixed lease err1 > @@ -943,6 +944,7 @@ WARNING: untranslated string: access point name is invalid = Access Point Name i > WARNING: untranslated string: access point name is required = Access Point Name is required > WARNING: untranslated string: bytes = unknown string > WARNING: untranslated string: cpu frequency = CPU frequency > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dns servers = DNS Servers > WARNING: untranslated string: error message = unknown string > WARNING: untranslated string: fwhost cust locationgrp = unknown string > diff --git a/doc/language_issues.fr b/doc/language_issues.fr > index 56d69d86e..cb06f0ab3 100644 > --- a/doc/language_issues.fr > +++ b/doc/language_issues.fr > @@ -392,7 +392,6 @@ WARNING: translation string unused: generatepolicy > WARNING: translation string unused: generatereport > WARNING: translation string unused: genkey > WARNING: translation string unused: green interface > -WARNING: translation string unused: guaranteed bandwith > WARNING: translation string unused: guest ok > WARNING: translation string unused: gz with key > WARNING: translation string unused: harddisk temperature graphs > @@ -404,6 +403,7 @@ WARNING: translation string unused: host deny > WARNING: translation string unused: hostname and domain already in use > WARNING: translation string unused: hour-graph > WARNING: translation string unused: hours2 > +WARNING: translation string unused: ibod for dual isdn only > WARNING: translation string unused: icmp selected but no type > WARNING: translation string unused: icmp type > WARNING: translation string unused: id > @@ -453,6 +453,10 @@ WARNING: translation string unused: ipblocklist category scanner > WARNING: translation string unused: ipfire side > WARNING: translation string unused: ipsec no connections > WARNING: translation string unused: iptable rules > +WARNING: translation string unused: isdn > +WARNING: translation string unused: isdn settings > +WARNING: translation string unused: isdn1 > +WARNING: translation string unused: isdn2 > WARNING: translation string unused: javascript menu error1 > WARNING: translation string unused: javascript menu error2 > WARNING: translation string unused: kernel version > @@ -908,15 +912,11 @@ WARNING: translation string unused: zoneconf val zoneslave amount error > WARNING: untranslated string: access point name = Access Point Name > WARNING: untranslated string: access point name is invalid = Access Point Name is invalid > WARNING: untranslated string: access point name is required = Access Point Name is required > -WARNING: untranslated string: advproxy errmsg invalid url = Invalid URL > WARNING: untranslated string: core notice 3 = available. > -WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > -WARNING: untranslated string: email recipient invalid = Invalid email recipient > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: error message = unknown string > WARNING: untranslated string: fwhost cust locationgrp = unknown string > WARNING: untranslated string: fwhost err hostip = unknown string > -WARNING: untranslated string: guaranteed bandwidth = Guaranteed bandwidth > WARNING: untranslated string: guardian block a host = unknown string > WARNING: untranslated string: guardian block httpd brute-force = unknown string > WARNING: untranslated string: guardian block ssh brute-force = unknown string > @@ -947,9 +947,6 @@ WARNING: untranslated string: guardian logtarget_syslog = unknown string > WARNING: untranslated string: guardian no entries = unknown string > WARNING: untranslated string: guardian service = unknown string > WARNING: untranslated string: pakfire ago = ago. > -WARNING: untranslated string: retbleed = Retbleed > WARNING: untranslated string: route config changed = unknown string > WARNING: untranslated string: routing config added = unknown string > WARNING: untranslated string: routing config changed = unknown string > -WARNING: untranslated string: service boot setting unavailable = No valid runlevel symlink was found for the initscript of this service. > -WARNING: untranslated string: show dh = Show Diffie-Hellman parameters > diff --git a/doc/language_issues.it b/doc/language_issues.it > index 9999f947c..dd794f57a 100644 > --- a/doc/language_issues.it > +++ b/doc/language_issues.it > @@ -940,13 +940,13 @@ WARNING: untranslated string: dangerous = Dangerous > WARNING: untranslated string: default IP address = Default IP Address > WARNING: untranslated string: desired = Desired > WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > WARNING: untranslated string: dhcp deny known clients: = Deny known clients: > WARNING: untranslated string: dhcp dns enable update = Enable DNS Update (RFC2136): > WARNING: untranslated string: dhcp dns key name = Key Name > WARNING: untranslated string: dhcp dns update = DNS Update > WARNING: untranslated string: dhcp dns update algo = Algorithm > WARNING: untranslated string: dhcp dns update secret = Secret > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dhcp make fixed lease = Add to fix leases > WARNING: untranslated string: dhcp valid range required when deny known clients checked = Valid range required when "Deny known clients:" is checked > WARNING: untranslated string: disable = Disable > diff --git a/doc/language_issues.nl b/doc/language_issues.nl > index 14a7b420e..4f100abd2 100644 > --- a/doc/language_issues.nl > +++ b/doc/language_issues.nl > @@ -943,12 +943,12 @@ WARNING: untranslated string: default = Default > WARNING: untranslated string: default IP address = Default IP Address > WARNING: untranslated string: desired = Desired > WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > WARNING: untranslated string: dhcp dns enable update = Enable DNS Update (RFC2136): > WARNING: untranslated string: dhcp dns key name = Key Name > WARNING: untranslated string: dhcp dns update = DNS Update > WARNING: untranslated string: dhcp dns update algo = Algorithm > WARNING: untranslated string: dhcp dns update secret = Secret > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dhcp make fixed lease = Add to fix leases > WARNING: untranslated string: disable = Disable > WARNING: untranslated string: disconnected = Disconnected > diff --git a/doc/language_issues.pl b/doc/language_issues.pl > index a53a208d9..e91e62c5b 100644 > --- a/doc/language_issues.pl > +++ b/doc/language_issues.pl > @@ -915,13 +915,13 @@ WARNING: untranslated string: default IP address = Default IP Address > WARNING: untranslated string: desired = Desired > WARNING: untranslated string: details = Details > WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > WARNING: untranslated string: dhcp deny known clients: = Deny known clients: > WARNING: untranslated string: dhcp dns enable update = Enable DNS Update (RFC2136): > WARNING: untranslated string: dhcp dns key name = Key Name > WARNING: untranslated string: dhcp dns update = DNS Update > WARNING: untranslated string: dhcp dns update algo = Algorithm > WARNING: untranslated string: dhcp dns update secret = Secret > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dhcp make fixed lease = Add to fix leases > WARNING: untranslated string: dhcp valid range required when deny known clients checked = Valid range required when "Deny known clients:" is checked > WARNING: untranslated string: disable = Disable > diff --git a/doc/language_issues.ru b/doc/language_issues.ru > index c5dc1aa61..7dd1a63d7 100644 > --- a/doc/language_issues.ru > +++ b/doc/language_issues.ru > @@ -911,13 +911,13 @@ WARNING: untranslated string: default IP address = Default IP Address > WARNING: untranslated string: desired = Desired > WARNING: untranslated string: details = Details > WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > WARNING: untranslated string: dhcp deny known clients: = Deny known clients: > WARNING: untranslated string: dhcp dns enable update = Enable DNS Update (RFC2136): > WARNING: untranslated string: dhcp dns key name = Key Name > WARNING: untranslated string: dhcp dns update = DNS Update > WARNING: untranslated string: dhcp dns update algo = Algorithm > WARNING: untranslated string: dhcp dns update secret = Secret > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dhcp make fixed lease = Add to fix leases > WARNING: untranslated string: dhcp valid range required when deny known clients checked = Valid range required when "Deny known clients:" is checked > WARNING: untranslated string: disable = Disable > diff --git a/doc/language_issues.tr b/doc/language_issues.tr > index 552082a96..3443b1f1a 100644 > --- a/doc/language_issues.tr > +++ b/doc/language_issues.tr > @@ -926,8 +926,8 @@ WARNING: untranslated string: dangerous = Dangerous > WARNING: untranslated string: default IP address = Default IP Address > WARNING: untranslated string: desired = Desired > WARNING: untranslated string: dh = Diffie-Hellman-Parameter > -WARNING: untranslated string: dh parameter = unknown string > WARNING: untranslated string: dhcp deny known clients: = Deny known clients: > +WARNING: untranslated string: dhcp fixed ip address in dynamic range = Fixed IP Address in dynamic range > WARNING: untranslated string: dhcp make fixed lease = Add to fix leases > WARNING: untranslated string: dhcp valid range required when deny known clients checked = Valid range required when "Deny known clients:" is checked > WARNING: untranslated string: disable = Disable > diff --git a/doc/language_missings b/doc/language_missings > index 65d38b422..78b9e8a2d 100644 > --- a/doc/language_missings > +++ b/doc/language_missings > @@ -47,6 +47,7 @@ > < could not connect to www ipfire org > < cryptographic settings > < desired > +< dhcp fixed ip address in dynamic range > < dhcp server disabled on blue interface > < dhcp server enabled on blue interface > < disable > @@ -102,6 +103,7 @@ > < access point name is required > < addon > < cpu frequency > +< dhcp fixed ip address in dynamic range > < dns servers > < hardware vulnerabilities > < invalid ip or hostname > @@ -115,18 +117,12 @@ > < access point name > < access point name is invalid > < access point name is required > -< advproxy errmsg invalid url > < ansi t1.483 > < bewan adsl pci st > < bewan adsl usb > -< dh > -< email recipient invalid > +< dhcp fixed ip address in dynamic range > < g.dtm > < g.lite > -< guaranteed bandwidth > -< retbleed > -< service boot setting unavailable > -< show dh > < upload fcdsl.o > ############################################################################ > # Checking cgi-bin translations for language: it # > @@ -252,6 +248,7 @@ > < dhcp dns update > < dhcp dns update algo > < dhcp dns update secret > +< dhcp fixed ip address in dynamic range > < dhcp make fixed lease > < dhcp valid range required when deny known clients checked > < disable > @@ -756,6 +753,7 @@ > < dhcp dns update > < dhcp dns update algo > < dhcp dns update secret > +< dhcp fixed ip address in dynamic range > < dhcp make fixed lease > < disable > < Disabled > @@ -1353,6 +1351,7 @@ > < dhcp dns update > < dhcp dns update algo > < dhcp dns update secret > +< dhcp fixed ip address in dynamic range > < dhcp make fixed lease > < dhcp valid range required when deny known clients checked > < disable > @@ -2330,6 +2329,7 @@ > < dhcp dns update > < dhcp dns update algo > < dhcp dns update secret > +< dhcp fixed ip address in dynamic range > < dhcp make fixed lease > < dhcp valid range required when deny known clients checked > < disable > @@ -3173,6 +3173,7 @@ > < desired > < dh > < dhcp deny known clients: > +< dhcp fixed ip address in dynamic range > < dhcp make fixed lease > < dhcp valid range required when deny known clients checked > < disable > diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi > index 2d162b204..1b1102932 100644 > --- a/html/cgi-bin/dhcp.cgi > +++ b/html/cgi-bin/dhcp.cgi > @@ -127,6 +127,9 @@ my $extraHead = < } > .cell-orange { > background-color: orange; > + } > + .cell-red { > + background-color: red; > } > > END > @@ -1042,8 +1045,9 @@ my $ipdup = 0; > my %ipinuse = (); > my %macdupl = (); # Duplicate MACs have to be on different subnets > my %ipoutside = (); > +my %ipinrange = (); > > -# mark duplicate ip or duplicate MAC > +# mark duplicate IP, duplicate MAC or IP in dynamic range > foreach my $line (@current2) { > my @temp = split(/\,/,$line); > $macdupl{$temp[0]} += 1; > @@ -1054,14 +1058,21 @@ foreach my $line (@current2) { > if ($ipinuse{$temp[1]} > 1) { > $ipdup = 1; # Flag up duplicates for use later > } > - # Mark IP addresses outwith known subnets > $ipoutside{$temp[1]} = 1; > + $ipinrange{$temp[1]} = 0; > foreach my $itf (@ITFs) { > - if ( &General::IpInSubnet($temp[1], > - $netsettings{"${itf}_NETADDRESS"}, > - $netsettings{"${itf}_NETMASK"})) { > - $ipoutside{$temp[1]} = 0; > - } > + # Mark IP addresses outwith known subnets > + if ( &General::IpInSubnet($temp[1], > + $netsettings{"${itf}_NETADDRESS"}, > + $netsettings{"${itf}_NETMASK"})) { > + $ipoutside{$temp[1]} = 0; > + } > + # Mark IP addresses that overlap with dynamic range > + if (&Network::ip_address_in_range($temp[1], > + $dhcpsettings{"START_ADDR_${itf}"}, > + $dhcpsettings{"END_ADDR_${itf}"})) { > + $ipinrange{$temp[1]} = 1; > + } > } > } > > @@ -1115,6 +1126,9 @@ foreach my $line (@current2) { > if ($ipoutside{$temp[1]} > 0) { > $TAG4 = "class='cell-orange'" if ($dhcpsettings{'KEY2'} ne $key); > } > + if ($ipinrange{$temp[1]} > 0) { > + $TAG4 = "class='cell-red'" if ($dhcpsettings{'KEY2'} ne $key); > + } > > print < $TAG2$temp[0]$TAG3 > @@ -1177,6 +1191,8 @@ print <   >   > $Lang::tr{'ip address outside subnets'} > +    > + $Lang::tr{'dhcp fixed ip address in dynamic range'} >   >   > $dup > diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl > index 80753b841..5a72f53b8 100644 > --- a/langs/en/cgi-bin/en.pl > +++ b/langs/en/cgi-bin/en.pl > @@ -827,6 +827,7 @@ > 'dhcp dns update' => 'DNS Update', > 'dhcp dns update algo' => 'Algorithm', > 'dhcp dns update secret' => 'Secret', > +'dhcp fixed ip address in dynamic range' => 'Fixed IP Address in dynamic range', > 'dhcp fixed lease err1' => 'For a fix lease you have to enter the MAC address or the hostname, or you enter both.', > 'dhcp fixed lease help1' => 'IP Addresses might be entered as FQDN', > 'dhcp make fixed lease' => 'Add to fix leases',