FOG DHCP bug/feature request
-
FOG currently does not detect subnet masks correctly, and therefore gets the network address and IP ranges wrong when you install fog with DHCP.
Additionally, after correcting the dhcpd.conf file and restarting DHCP, every single time you update or re-run the installer, the FOG installer wipes the dhcpd.conf file and rewrites it with incorrect information.
If the subnet mask can be detected properly, that’d be good… but…
What I REALLY want is for the installer to not touch the dhcpd.conf file after the initial installation using DHCP.
Here, we have a mixture of static and dynamic addressing. Printers and servers and an amount of user computers are static and exist within a certain range. We cannot let DHCP operate within those ranges and must set our DHCP to not serve those address ranges.
So, I’d rather the installer not touch the dhcpd.conf file after initial installation - just leave it alone, please.
Currently, I’m having to make a copy of the file after it’s setup correctly, and after every upgrade, I have to copy my copy back to the correct file name and restart DHCP.
-
Can an option be built into the installer to not alter the dhcpd.conf file?
Like an argument for the installer?
-
Wayne,
I think the simplest approach, once you’ve already got this all setup, is just change the fogsettings file to NOT do anything with dhcp.
-
Change dodhcp to read as dodhcp=“n”;
Change bldhcp to read as bldhcp=“1”; -
@Tom-Elliott said:
Change dodhcp to read as dodhcp=“n”;
Change bldhcp to read as bldhcp=“1”;This didn’t work, the installer wrote over the dhcpd.conf file again (no biggie, I had a backup).
Did you mean bldhcp=“0” instead of “1” ??
Because I noticed it was already set to 1.
-
@Wayne-Workman yes, I meant 0, sorry.
-
The changes that were suggested were made and then the installer was run again. The installer overwrote the dhcpd.conf file again.
Here is the .fogsettings file:
Passwords have been omitted.
ipaddress="10.12.1.11"; interface="eno1"; routeraddress=" option routers 10.12.15.254;"; plainrouter="10.12.15.254"; dnsaddress=" option domain-name-servers 10.51.1.6; "; dnsbootimage="10.51.1.6"; password='xxxxxxxxx'; osid="1"; osname="Redhat"; dodhcp="n"; bldhcp="0"; installtype="N"; snmysqluser="" snmysqlpass=''; snmysqlhost=""; installlang="0"; donate="0"; storageLocation="/images"; mysql_conntype="MYSQLI_ASYNC"; fogupdateloaded="1"; storageftpuser="fog"; storageftppass='xxxxxxxxxxx'; docroot="/var/www/html/"; webroot="fog/"; caCreated="yes";
I’m working on modifying the installer to correctly build the dhcpd.conf file and offer options to the user on ranges. I’ll post it when I’m done.
-
@Wayne-Workman I’ve added two new functions to the installer itself. cidr2mask and mask2cidr. We probably only need to worry about the cidr2mask function but I figure if it’s worth doing, it’s worth doing in both directions.
I’m also rewriting the configureDHCP function to be in the common/functions.sh and going to work on getting it to automate this.
For example, ranges should really be determined by the subnet mask of the network you’re working with. Of course you want the range to not include your FOG Server’s IP, so maybe just +1 form the fog server’s IP and up would work.
-
@Tom-Elliott said:
Of course you want the range to not include your FOG Server’s IP, so maybe just +1 form the fog server’s IP and up would work.
Our fog server is not the only static IP we have, we have 20 or so network printers, 5 servers, probably 20 or 30 switches, network connected battery backups, and 20 to 25 regular desktops that are static.
our subnet range is 10.2.0.0 to 10.2.15.254
Our DHCP range is 10.2.3.0 to 10.2.12.255 and the edges that arent’ included are purposely reserved for static IPs.
Of course not everyone uses BOTH edges, but we do. I think the default range should be displayed to the user during the installer, and the user can accept it, or define their own range if they would like, just like other fog options are set up.
-
From a lot of posts around the net, I’ve been able to put this together. It accurately returns the subnet mask for the default interface.
function GetLocalSubnetMask() { #get default interface's IP and subnet mask. default_info=$(ip route list | awk '/^default/ {print $5}') default_info=$(ip -o -f inet addr show $default_info | awk '{print $4}') #cut the CIDR value off: CIDR=${default_info#*/} #Convert CIDR to subnet mask: local i mask="" local full_octets=$(($CIDR/8)) local partial_octet=$(($CIDR%8)) for ((i=0;i<4;i+=1)); do if [ $i -lt $full_octets ]; then mask+=255 elif [ $i -eq $full_octets ]; then mask+=$((256 - 2**(8-$partial_octet))) else mask+=0 fi test $i -lt 3 && mask+=. done echo $mask } SubnetMask=$(GetLocalSubnetMask) echo $SubnetMask
-
While I’m not resolving this post quite yet the current version of trunk/dev fog now create the subnet place holder based on the fog servers ip subnet. This will likely fail for those using hostnames as the ip which I need to get the real interfaces ip, based on the interface if specified.
-
@Tom-Elliott Just an update on this, I was able to play with the latest FOG Trunk today (don’t know what revision), and I noticed that the subnet mask is calculated CORRECTLY, however the network address and ranges are still wrong.
I’m not sure how far along in implementation this is, I’m just reporting on what was seen.
-
Here are the .fogsettings and dhcpd.conf files from that location. We re-enabled DHCP in the.fogsettings file and we updated to the latest this morning. Progress is looking good, but the ranges didn’t use what we defined during installation.
We use the -s and -e arguments to install like this:
./installfog.sh -s 10.12.5.0 -e 10.12.7.255 -y
However you will see below that the ranges passed to the installer were not stored correctly inside of .fogsettings (unless we passed the ranges wrong in the install command?).
Also - even after we manually corrected the start and end ranges in the .fogsettings file and reran the installer using just the -y argument, it did not use the specified start and end addresses and used what is seen below in the dhcpd.conf file.
However we have noticed that now the subnet masks and the network address are correct.
Also, a much more minor problem, there’s some formatting issues in the installer output - trivial. See the picture at the end.
[root@CKFOG dhcp]# cat /opt/fog/.fogsettings ## Created by the FOG Installer ## Version: 4301 ## Install time: Tue 04 Aug 2015 07:33:29 AM CDT ipaddress="10.12.1.11"; interface="eno1"; submask="255.255.240.0"; routeraddress=" option routers 10.12.15.254;"; plainrouter="10.12.15.254"; dnsaddress=" option domain-name-servers 10.51.1.6; "; dnsbootimage="10.51.1.6"; password='xxxxxxxxx'; osid="1"; osname="Redhat"; dodhcp="y"; bldhcp="1"; installtype="N"; snmysqluser="" snmysqlpass=''; snmysqlhost=""; installlang="0"; donate="0"; storageLocation="/images"; mysql_conntype="MYSQLI_ASYNC"; fogupdateloaded="1"; storageftpuser="fog"; storageftppass='xxxxxxxxxxxx'; docroot="/var/www/html/"; webroot="fog/"; caCreated="yes"; startrange="10.12.1.10"; endrange="10.12.1.254";
[root@CKFOG dhcp]# cat dhcpd.conf # DHCP Server Configuration file #see /usr/share/doc/dhcp*/dhcpd.conf.sample # This file was created by FOG #Definition of PXE-specific options # Code 1: Multicast IP Address of bootfile # Code 2: UDP Port that client should monitor for MTFTP Responses # Code 3: UDP Port that MTFTP servers are using to listen for MTFTP requests # Code 4: Number of seconds a client must listen for activity before trying # to start a new MTFTP transfer # Code 5: Number of seconds a client must listen before trying to restart # a MTFTP transfer option space PXE; option PXE.mtftp-ip code 1 = ip-address; option PXE.mtftp-cport code 2 = unsigned integer 16; option PXE.mtftp-sport code 3 = unsigned integer 16; option PXE.mtftp-tmout code 4 = unsigned integer 8; option PXE.mtftp-delay code 5 = unsigned integer 8; option arch code 93 = unsigned integer 16; # RFC4578 use-host-decl-names on; ddns-update-style interim; ignore client-updates; next-server 10.12.1.11; # Specify subnet of ether device you do NOT want service. for systems with # two or more ethernet devices. # subnet 136.165.0.0 netmask 255.255.0.0 {} subnet 10.12.0.0 netmask 255.255.240.0 { option subnet-mask 255.255.240.0; range dynamic-bootp 10.12.1.10 10.12.1.254; default-lease-time 21600 max-lease-time 43200; option domain-name-servers 10.51.1.6; option routers 10.12.15.254; filename ; }
-
@Wayne-Workman I’m going to solve this thread. Of course if there’s other issues I need to be made aware of about this, go ahead an reset as unsolved and add your info.
Thanks.
-
@Developers this is r4339 on Fedora 21
There is a bug in the current DHCP config generated by fog.
#This line is missing the colon at the end: default-lease-time 21600; #This line is missing the default undionly.kpxe file name. filename "undionly.kpxe";
Also, it would seem that Linux DHCP cannot run on the same machine that dnsmasq is running on
-
@Tom-Elliott I installed using this line at home:
./installfog.sh -s 10.0.0.21 -e 10.0.0.254 -y
And it did not store the range in the /etc/dhcp/dhcpd.conf file.
I did install with DHCP just prior to trying this - and previously the conf file had 10.0.0.20 as the start range because I manually edited it. I just ran the installer with the above arguments to see if it would update the starting range. It did not update it.
-
This is now fixed in svn/trunk/git whatever you want to call it.
I confirmed that it stores the IP and knows that it’s valid.
SVN 3861, FOG Version in cloud is: 4353.
Thank you,