Linux Replace ip in resolv.conf with domain name lookup

Date: 2018-03-29
#!/bin/bash
host_name=my-proxy-domain.com
ip_addr=$(getent hosts $host_name | cut -f1 -d' ')
echo "Proxy: $ip_addr"
replace_cmd='/proxy\.lan/c\'"$ip_addr\t proxy.lan #replaced"
echo "Cmd: $replace_cmd"
sed -i "$replace_cmd" /etc/hosts

 

10710cookie-checkLinux Replace ip in resolv.conf with domain name lookup