iptables allow port from code example
Example 1: iptables open port
sudo iptables -A INPUT -p tcp --dport xxxx -j ACCEPT
Example 2: iptables block incoming port
iptables -A INPUT -p tcp --dport 8000 -s 1.2.3.4 -j ACCEPT
iptables -A INPUT -p tcp --dport 8000 -j DROP