We need many more specifics here obviously. What type of UDP attack? DOS or DDOS? Which port? What type of system are you running? etc, etc, etc..
You can block All UDP traffic except dns by configuring rules in Firewall. iptables -A INPUT -p udp --sport 53 -j ACCEPT iptables -A INPUT -p udp --dport 53 -j ACCEPT iptables -A OUTPUT -p udp --sport 53 -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT iptables -A INPUT -p udp -j DROP iptables -A OUTPUT -p udp -j DROP
A DoS Attack Iptables will be able to thwart however a DDos attack with more packets per second IP tables won't be able to help unless your port is big enough to absorb attacks, the only 100% Full proof solution is to get a DDoS Protected VPS or Dedicated Server.