Error while executing the dig command

1.0 Error

While executing the dig command, the sendmsg() failed: Operation not permitted error was printed.

$ dig example.com
../../../../lib/isc/unix/net.c:581: sendmsg() failed: Operation not permitted
../../../../lib/isc/unix/net.c:581: sendmsg() failed: Operation not permitted
...

2.0 Solution

The error was resolved after adding the following iptables rules.

iptables -I OUTPUT 1 -p udp -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT 
ip6tables -I OUTPUT 1 -p udp -s 0000:0000:0000:0000:0000:0000:0000:0001 \
    -d 0000:0000:0000:0000:0000:0000:0000:0001 -j ACCEPT 

The above rules permit UDP messages over the loopback interface required for the DNS protocol.