The default DROP policy in your ruleset affects the replies: your query was done, a reply was sent back from remote to your server, and then your server dropped this reply. Final result: no reply meaning no connectivity.
Your last attempt with:
-A INPUT -p udp -m udp --sport 53 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --sport 53 -m state --state ESTABLISHED -j ACCEPT
should have made the DNS part work. Leading to the next step: an attempt to connect to the resource now it was resolved. But then again this attempt failed for the same reason: replies are dropped.
You're missing a generic stateful rule, which should be the very first rule in the ruleset:
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
It will allow replies to any query sent by the hosts itself, including related errors (typically reeived as ICMP) because such query is memorized by Netfilter's conntrack facility for stateful operations (and also for NAT when relevant).
Should a REJECT rule be added later, then above should be followed by:
-A INPUT -m conntrack --ctstate INVALID -j DROP
(that's not needed here).
To have this take effect immediately, just run as root, using -I
instead of -A
:
iptables -I INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
Note that Docker's containers are unaffected, because everything going to or from Docker's containers is routed (because of NAT), so traverses filter/FORWARD instead of filter/INPUT. They might still have been affected when relying on host's services, possibly DNS resolution.