First, check which ports netstat-anp has opened. Second, close the port number: iptables-a input-ptcp-drop port number -jdropptitables-aoutput-ptcp-dport port number-jdrop. Third, open the port number: iptables-a input-ptcp-dport port number -jACCEPT. Four, the following is the use of linux open port command. NC-LP23 (telnet) netstat-an | grep23 (check whether to open port 23) V. linux open port command Each open port needs a corresponding listener to suit the learning path of entry. Please read "This is how Linux should learn".
How do Linux servers open ports and configure firewalls?
Open the configuration file
Instruction code
#vi/etc/sysconfig/iptables
Correct configuration file
Configuration code
# firewall configurationwrittenbysystem-config-firewall
# manualizationofthisfileisnotrecommended。
* Filter
: Enter Accept
: Forward acceptance
: output accept
-ain put-mstate _ state established,RELATED-jACCEPT
-AINPUT-picmp-jACCEPT
-AINPUT-ilo-jACCEPT
-ain put-mstate _ state new-mtcp-ptcp _ d port 22-j cept
-ain put-mstate _ state new-mtcp-ptcp _ d port 80-j cept
-ainput-jreject _ reject-with icmp-host-forbidden
-a forward-j reject _ reject-with icmp-host-forbidden
commit a crime
Configure wildcard codes
-ain put-mstate _ state new-mtcp-ptcp _ dport *-JAC cept
Note: The newly opened port must be after port 22.
Restart the firewall for the configuration to take effect.
Instruction code
#/etc/init.d/iptablesrestart
other
View open ports
Instruction code
#/etc/init.d/iptablesstatus
Turn off the firewall
Instruction code
#/etc/init.d/iptablesstop
Linux can run multiple processes on a single port. For example, if I open two browsers at the same time, how many ports does it belong to?
Many processes can run on each port, and each process can call the same port, but when one process occupies the port, other processes will wait until the previous process releases the port before being called by the next process.
How to disable ports in linux system?
1, the port generally corresponds to the corresponding network service program. To disable a port, you can first check the service corresponding to the port. Then shut down the service. netstat-antup
2. You can also disable it through iptables. Take port 8080 as an example, and execute the following commands: iptables-ainput-ptcp-dport8080-jdropiptables-ainput-ptcp-sport8080-jdropiptables-ainput-pudp-dport8080-jdropiptables-ainput.
How to enable 8080 port in linuxwiki?
/sbin/iptables? -Me? Input? -p? tcp? -Port? 8080? -j? Accept # open port 8080 /etc/rc.d/init.d/iptables? Save# saves the changes to the firewall.