Method 1: Command line method
1. Open port command:
/sbin/iptables -I INPUT -p tcp --dport 8080 -j` ACCEPT
2. Save:
/etc/rc.d/init.d/iptables save
3. Restart the service:
/etc/init.d/iptables restart
4. Check whether the port is open:
/sbin/iptables -L -n
Free video tutorial recommendation:linux video tutorial
Method 2: Direct editing/etc/sysconfig/iptables
File
1. Edit the /etc/sysconfig/iptables file
vi /etc/sysconfig/iptables
Add the following content and save:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
2. Restart the service:
/etc/init.d/iptables restart
3. Check whether the port is open
/sbin/iptables -L -n
To check whether there is a process guarding the port, use the following command, grep the corresponding port, such as 80 is the port number
netstat -nalp|grep 80
related Recommended article tutorials:linux tutorial
The above is the detailed content of How to open specified port in linux. For more information, please follow other related articles on the PHP Chinese website!