How to block access to a local user to a local port?

Solution 1:

The full command as mentioned by Iain would look something like this

iptables -t filter -A OUTPUT -p tcp --dport 25600 --match owner --uid-owner 503 -j DROP

Just remember to edit the --uid-owner 503 to the correct UID for user Elvis

Solution 2:

Iptables has an owner module that you can use

This module attempts to match various characteristics of the packet creator, for locally-generated packets. It is only valid in the OUTPUT chain, and even this some packets (such as ICMP ping responses) may have no owner, and hence never match.

You would want to use

--uid-owner userid Matches if the packet was created by a process with the given effective user id.

You just need to combine this with other suitable iptables parameters e.g. --dport to make the filter that works for you.