Skip to content

Instantly share code, notes, and snippets.

@nevermosby
Last active April 4, 2024 00:40
Show Gist options
  • Select an option

  • Save nevermosby/88efb9ecc4e61b8f401d449649796dfc to your computer and use it in GitHub Desktop.

Select an option

Save nevermosby/88efb9ecc4e61b8f401d449649796dfc to your computer and use it in GitHub Desktop.
build curl with c ares for custom dns server
## for some distributions of Linix, like ubuntu 18.04
## `curl` does not include `c-ares` module so that you cannot do `curl --dns-servers 8.8.8.0 www.example.com`
## you will get error message as below:
## curl: (4) A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision.
# build curl from source code
# You can do that with building `curl` from souce code. below is tested against ubuntu 18.04
# download the code from git repo
git clone https://github.com/curl/curl.git && cd curl
# if the build machine does not have all the dependencies already, u will get errors.
# u can find them here: https://github.com/curl/curl/blob/master/GIT-INFO#L29
./buildconf
# once the file `configure` is generated, u are ready to go
./configure -h
# install the lib of c-ares as we want to build with it
apt install -y libc-ares-dev
# use `configure` and `make` to build from source
# `--enable-ares` for enabling c-ares
# `--prefix` for installation path
./configure --enable-ares --prefix=/usr/local/curl/fromsource # add more module if u want
make
make install
# once it is completed, u can find the new `curl` binary in ur installation path
cd /usr/local/curl/fromsource/bin/ && ls
curl curl-config
# Use new `curl`
# create a link for new `curl`
ln -s /usr/local/curl/fromsource/bin/curl /usr/local/bin/curl-new
# specify the lib path for new `curl`
export LD_LIBRARY_PATH=/usr/local/curl/fromsource/lib
# specify the custom dns server and there u go
curl-new --dns-servers 8.8.8.8 www.example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment