Home > Back-end >  Linux how to open a port number
Linux how to open a port number

Time:12-03

Method one:
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 services:/etc/init. D/iptables restart
4. Check to see if the port is open:/sbin/iptables - L - n

Method 2:
1. Edit/etc/sysconfig/iptables documents: vi/etc/sysconfig/iptables
Add content and save: - A RH - Firewall - 1 - INPUT - m state - the state NEW -m TCP -p TCP -- dport 8080 - j ACCEPT
2. Restart services:/etc/init. D/iptables restart
3. Check to see if the port open:/sbin/iptables - L - n

Query port if there is a process to protect with the following command grep corresponding port, such as 80 for port
Example: netstat nalp | grep, 80

CodePudding user response:

The
refer to the original poster liukaijunabc123 response:
method one:
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 services:/etc/init. D/iptables restart
4. Check to see if the port is open:/sbin/iptables - L - n

Method 2:
1. Edit/etc/sysconfig/iptables documents: vi/etc/sysconfig/iptables
Add content and save: - A RH - Firewall - 1 - INPUT - m state - the state NEW -m TCP -p TCP -- dport 8080 - j ACCEPT
2. Restart services:/etc/init. D/iptables restart
3. Check to see if the port open:/sbin/iptables - L - n

Query port if there is a process to protect with the following command grep corresponding port, such as 80 for port
Example: netstat nalp | grep 80


+ 1

CodePudding user response:

Depends on the system, such as Centos7 and above, as a kind of low-level iptables has achieved, the default is no this command, and now the mainstream to nftables transformation, iptables no slowly, in addition to match ports in the firewall, and Selinux also want to set,
  • Related