Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Created February 8, 2022 06:39
Show Gist options
  • Save Esonhugh/c981d6209daa037c6bc5904e384bd0d0 to your computer and use it in GitHub Desktop.
Save Esonhugh/c981d6209daa037c6bc5904e384bd0d0 to your computer and use it in GitHub Desktop.
covert the dnsmasq format ip hosts to hosts file command
export your_domain=Whoami.dn42 # or .local .localdomain ...etc
cat /etc/dnsmasq.conf |grep $your_domain |grep address |cut -d "/" -f 2,3 |sed -e "s/\//\t/g" |awk '{print $2 "\t" $1}'
## from dnsmasq to hosts
cat /etc/dnsmasq.conf |grep $your_domain |grep address |cut -d "/" -f 2,3 |sed -e "s/\//\t/g" |awk '{print $2 "\t" $1}' |tee -a /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment