How To Choose a Specific IP Address From a DNS Result?

Photo by Jordan Harrison on Unsplash
74.6.231.20, 74.6.143.26, 74.6.143.25, 98.137.11.164, 98.137.11.163, 74.6.231.21
scopev4 ::ffff:98.137.11.0/120 3
scopev4 ::ffff:74.6.231.0/120 2
scopev4 ::ffff:74.6.143.0/120 1

Second column is the IP subnet, third column is the priority. The lower number has high priority.

1) Call getaddrinfo
2) Get IP address of yahoo.com
3) Check if there is a rule for these IP addresses in the gai.conf file
4) Get the one that has high priority. If an IP address of yahoo.com is not listed in gai.conf and getaddrinfo would return that IP.
root@adil:~# systemd-resolve --flush-caches && ping yahoo.com -c1PING yahoo.com (74.6.143.25) 56(84) bytes of data.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CG Pipeline: In-House Development vs Commercial Solution

dClimate Tech Update

Denormalized indexing with elasticsearch-rails

After Agile: The Asynchronous Future

7 things any Java developer should know when starting with Kotlin

[008]Reverse String 344 反轉字串

A Decade with Distributed Systems — My Experience

How to make a simple HTTP server using python?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
adil

adil

More from Medium

Zabbix Upgrade 4.4 to 5.0 using Centos 8

Start a VMware vSphere Virtual Machine — Ansible module vmware_guest_powerstate

Linux Command -Line Warmup !!

LVM in Linux — Create and Extend a Logical Volume