Compiling dnsmasq 2.76 if you need uefi support
-
If you have Centos 7, there is no direct path to compiling your own version of dnsmasq. I did find a precompiled rpm of dnsmasq 2.76 here: http://rpm.pbone.net/index.php3/stat/4/idpl/35995670/dir/centos_7/com/dnsmasq-2.76-1cnt7.x86_64.rpm.html
-
Ubuntu 16.04 LTS based systems
Build system: Mint 18 x64 (Based on Ubuntu 16.04 LTS)
(note the following instructions worked perfectly for Raspbian Jessie which is Debian based)- First we need to setup our build environment
sudo apt-get update sudo apt-get install build-essential sudo apt-get install -y wget libdbus-1-dev libnetfilter-conntrack-dev idn libidn11-dev nettle-dev libval-dev dnssec-tools
- Next we’ll get the source code for dnsmasq 2.76 Note: version 2.77 has been released. I have not tested it yet, but I suspect the same process can be used to compile 2.77 as 2.76
wget http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.76.tar.gz
- Extract the source code from the tar file
tar -zxf dnsmasq-2.76.tar.gz
- Change into the dnsmasq build directory
cd dnsmasq-2.76
- Lets update a few settings in the config file. I know there are other ways to go about this with command line switches, but I didn’t
sudo vi src/config.h
- Find this section
/* #define HAVE_LUASCRIPT */ /* #define HAVE_DBUS */ /* #define HAVE_IDN */ /* #define HAVE_CONNTRACK */ /* #define HAVE_DNSSEC */
- Paste in these settings just below the above text
#define HAVE_DBUS #define HAVE_IDN #define HAVE_IDN_STATIC #define HAVE_CONNTRACK #define HAVE_DNSSEC
- Save and exit the config.h file.
- We need to see where the current dnsmasq file is located. (NOTE: Please be sure that dnsmasq has already been installed in your linux distribution to ensure all of the dependences have been installed before we proceed).
which dnsmasq
10 This command should respond with something like this:
# which dnsmasq /usr/sbin/dnsmasq
- The key bit of info here is that dnsmasq is installed in /usr/sbin. What we need to do is tell the install script to not place the dnsmasq files in the default location (according to dnsmasq of /usr/local/sbin) but to place the files where the distribution dnsmasq put them (/usr/sbin). SO in this case we want to overwrite the dnsmasq binary in /usr/sbin. To do this we need to update the prefix variable in the Makefile (compiler instruction file).
- Since we know where dnsmasq is now, lets go and update the Makefile to reflect the location where we dnsmasq installed.
sudo vi Makefile
- Search for this line and change
PREFIX = /usr/local # To this PREFIX = /usr
- Save and exit out of the Makefile
- Lets backup the original dnsmasq executable just in case…
sudo cp /usr/sbin/dnsmasq /usr/sbin/dnsmasq.old
- Ok here’s where we create and install the latest version of dnsmasq
sudo make install
At this point the compiler will dig through the source code and compile the dnsmasq program. Hopefully it will compile and install without errors.
- Once the install is done lets ensure that the right version of dnsmasq is found first in the search path.
- Key in the following
dnsmasq -v
The output should look like this:
Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley Compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify This software comes with ABSOLUTELY NO WARRANTY. Dnsmasq is free software, and you are welcome to redistribute it under the terms of the GNU General Public License, version 2 or 3.
- Ensure the version displays 2.76 if so you are all set.
- The last and final step is to ensure that the application runs when the service is called.
sudo service dnsmasq restart
- If the service starts correctly (no errors) then you’re done.
- If you question if dnsmasq is running the proper version you can always inspect /var/log/syslog for any dnsmasq error messages.
As a suggestion you should be able to use this configuration for your new version of dnsmasq that is configured for both bios and uefi operations.
# Don't function as a DNS server: port=0 # Log lots of extra information about DHCP transactions. log-dhcp # Set the root directory for files available via FTP. tftp-root=/tftpboot # The boot filename, Server name, Server Ip Address dhcp-boot=undionly.kpxe,,<fog_server_IP> # Disable re-use of the DHCP servername and filename fields as extra # option space. That's to avoid confusing some old or broken DHCP clients. dhcp-no-override # inspect the vendor class string and match the text to set the tag dhcp-vendorclass=BIOS,PXEClient:Arch:00000 dhcp-vendorclass=UEFI32,PXEClient:Arch:00006 dhcp-vendorclass=UEFI,PXEClient:Arch:00007 dhcp-vendorclass=UEFI64,PXEClient:Arch:00009 # Set the boot file name based on the matching tag from the vendor class (above) dhcp-boot=net:UEFI32,i386-efi/ipxe.efi,,<fog_server_IP> dhcp-boot=net:UEFI,ipxe.efi,,<fog_server_IP> dhcp-boot=net:UEFI64,ipxe.efi,,<fog_server_IP> # PXE menu. The first part is the text displayed to the user. The second is the timeout, in seconds. pxe-prompt="Booting FOG Client", 1 # The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86, # Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI # This option is first and will be the default if there is no input from the user. pxe-service=X86PC, "Boot to FOG", undionly.kpxe pxe-service=X86-64_EFI, "Boot to FOG UEFI", ipxe.efi pxe-service=BC_EFI, "Boot to FOG UEFI PXE-BC", ipxe.efi dhcp-range=<fog_server_ip>,proxy
Don’t forget to replace <fog_server_ip> in the above text with the IP address of your fog server. The tag appears many times.
-
Steps 11 - 13 are confusing to me. You found that your dnsmasq binary is installed at
/usr/sbin/dnsmasq
but you changed the makefile’s prefix to be/usr
Also, wiki worthy
-
@Wayne-Workman said in Compiling dnsmasq 2.76 if you need uefi support:
Steps 11 - 13 are confusing to me. You found that your dnsmasq binary is installed at
/usr/sbin/dnsmasq
but you changed the makefile’s prefix to be/usr
Also, wiki worthy
If you looked in the Make file the prefix is the base of where stuff is installed. If you look at the lines just below that you will see that prefix is used for bindir and mandir variables. I use to do this kind of stuff all the time back in the early days (before the internet) so I forget some times that I need to add a bit of detail that I just intrinsically know.
I needed to find where the current dnsmasq binary file is located, because the default for dnsmasq source code would have been /usr/local/sbin instead of where the distribution package placed it in /usr/sbin. The issue is if I would not have changed this line two dnsmasq binaries would have been installed. Only the search path would determine which one would actually be called when the service started. That is a bit two random for me. So that is why I updated the script to just overwrite the existing dnsmasq program.
PREFIX = /usr BINDIR = $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man LOCALEDIR = $(PREFIX)/share/locale BUILDDIR = $(SRC) DESTDIR = CFLAGS = -Wall -W -O2 LDFLAGS = COPTS = RPM_OPT_FLAGS = LIBS =
-
@Wayne-Workman I updated #11 to hopefully clarify what my intent was.
-
This has been added to the wiki here:
-
I get the following error when trying to “Make install”
make[1]: *** [cache.o] error 1
/root/fogproject/bin/dnsmasq-2.76/Makefile:157: recipe for target ‘cache.o’ failed
make[1]: Leaving directory ‘/root/fogproject/bin/dnsmasq-2.76/src’
make: *** [all] Error 2
Makefile:83: recipe for target ‘all’ failedany suggestions?
-
@xerxes2985 What linux OS are you trying to compile this under?
-
@george1421 I got it working. My issue was that I erased some lines of code in the “vi src/config.h” portion of the when trying to edit in vim (I wasn’t sure how to edit the file in vim). Once I unpackaged the tarball again, I was able to get it compiled.
Thanks for responding.
-
So, Ubuntu 16’s default repository is now 1 point away from dnsmasq version 2.76.
As soon as all of the major distributions are including 2.76 in their default update repositories, then compiling your own will mostly be un-needed, and this will also greatly simplify the process of adding UEFI support to the MakeFogMobile project which utilizes dnsmasq.dnsmasq -v Dnsmasq version 2.75 Copyright (c) 2000-2015 Simon Kelley Compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify This software comes with ABSOLUTELY NO WARRANTY. Dnsmasq is free software, and you are welcome to redistribute it under the terms of the GNU General Public License, version 2 or 3.
-
My two cents.
In RHEL7 I have compiled the dnsmasq 0.78 version using these instructions and doing some changes.
Install the necesary packages:
sudo yum install nettle-devel sudo yum install libidn2-devel sudo yum install libnetfilter_conntrack-devel sudo yum install dbus-devel
config.h options:
/* #define HAVE_LUASCRIPT */ #define HAVE_DBUS /* #define HAVE_IDN*/ #define HAVE_LIBIDN2 #define HAVE_CONNTRACK #define HAVE_DNSSEC
Compiling and starting the service:
sudo make install sudo systemctl start dnsmasq sudo systemctl status dnsmasq
Output:
dnsmasq -v Dnsmasq version 2.78 Copyright (c) 2000-2017 Simon Kelley Compile time options: IPv6 GNU-getopt DBus no-i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify This software comes with ABSOLUTELY NO WARRANTY. Dnsmasq is free software, and you are welcome to redistribute it under the terms of the GNU General Public License, version 2 or 3.