dns snippets

"What's my IP" bash script

Tagged bash, wanip, ip, dns  Languages bash

This bash alias displays your IP address:

alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'

mDNS and DNS-SD example

Tagged dns, dns-sd, mdns, service discovery  Languages bash

To advertise the existence of an HTTP service with mDNS, use:

dns-sd -R "Service X" _http._tcp . 80 path=/

To find the HTTP services on the local network, run:

dns-sd -B _http._tcp

Browsing for _http._tcp
DATE: ---Wed 03 Mar 2021---
17:48:45.207  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
17:48:45.207  Add        2   9 local.               _http._tcp.          Service X

See /etc/services for a list of valid services.