Try to allow DNS :
sudo ufw allow dnsout 53
For your ping command ICMP rules
is also require you can read here.
# ok icmp codes
-A ufw-before-input -pallow icmpoutbound --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-inputoutput -p icmp --icmp-type source-quench -j ACCEPT
-A ufw-before-input -pm icmpstate --icmp-typestate time-exceededNEW,ESTABLISHED,RELATED -j ACCEPT
-A ufw-before-inputoutput -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-input -pm icmpstate --icmp-typestate echo-requestESTABLISHED,RELATED -j ACCEPT
For error Failed to fetch http://...
you need to allow http traffic for port 80.
sudo ufw allow out 80/tcp
After editing the file, run the command:
sudo ufw reload