First off, CentOS uses the firewall IPTables by default. To go in and open up ports you will need to start off as root :
sudo su –
You will be prompted for your root password. Go ahead and enter it and hit enter. It’s always a good idea to turn IPTables off before you start :
service iptables stop
Now you will need to run the following command based on if you want to open a TCP port or a UDP port :
iptables -I INPUT -p tcp –dport 12345 –syn -j ACCEPT
Make sure to change 12345 with the port you want to open
iptables -I INPUT -p udp –dport 12345 -j ACCEPT
Now you need to save the changes you’ve made to IPTables :
service iptables save
And finally, start the service back up :
service iptables start