The -d option is destination ip address (like 192.168.0.1), not destination port. What you want is --dport 515 instead. You will also get errors trying to do -p all --dport 515, because there are no port numbers for the icmp protocol. Only tcp and udp protocols use port numbers, so just make two rules:
iptables -A INPUT -p tcp --dport 515 -j DROP
iptables -A INPUT -p udp --dport 515 -j DROP
For port 6000 you have to be a little more careful, because it's the port that the Xserver connects to. If you block port 6000 to all interfaces, I'm pretty sure you won't be able to start X. So when you write that rule, remember to at least allow conections over the loopback interface. Something like this will do:
iptables -A INPUT -i !lo -p tcp --dport 6000 -j DROP
Where that is an exclaimation point before the lo. So what that's doing is saying "drop all connections to port 6000 that are not over the loopback interface".