After applying targeted modifications to the script, I was able to successfully execute it as intended.
#!/bin/sh
kill -9 $(cat /var/run/dnsmasq.pid)
DOMAIN=$(cat /etc/resolv.conf | grep search | awk {'print $2'})
if [ -z "$DOMAIN" ]; then
/pfrm2.0/bin/dnsmasq -y -x /var/run/dnsmasq.pid -h -H /var/hosts -c 0 \
--server=/file.core.windows.net/A.B.C.D
else
/pfrm2.0/bin/dnsmasq -y -x /var/run/dnsmasq.pid -h -H /var/hosts -c 0 -E --domain=# \
--server=/file.core.windows.net/A.B.C.D
fi
unset DOMAIN
The spaces are very important!!
To apply settings run the script:
[Expert@CKP]# sh /pfrm2.0/etc/userScript
To check configuration:
[Expert@CKP]# cat /proc/$(pidof dnsmasq)/cmdline | tr '\0' '\n'
/pfrm2.0/bin/dnsmasq
-y
-x
/var/run/dnsmasq.pid
-h
-H
/var/hosts
-c
0
-E
--domain=#
--server=/file.core.windows.net/A.B.C.D
To check if this configuration works:
[Expert@CKP]# nslookup aaaaaaaaaaa.file.core.windows.net 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1:53
Non-authoritative answer:
aaaaaaaaaaa.file.core.windows.net canonical name = aaaaaaaaaaa.privatelink.file.core.windows.net
Name: aaaaaaaaaaa.privatelink.file.core.windows.net
Address: 10.10.10.10
Non-authoritative answer:
aaaaaaaaaaa.file.core.windows.net canonical name = aaaaaaaaaaa.privatelink.file.core.windows.net