Linux opens firewall port and view, opens correlation and closes port number __linux

Source: Internet
Author: User
Tags iptables

When Linux opens the firewall, you will find that it is no problem to log on to port 23 from the local computer, but if you log on to the Linux system from another PC, you will notice that the error is prompted:

Unable to open connection to host on port 23: Connection Failed

Because the Linux firewall by default is 23 port, if Allow remote login, you can turn off the firewall, you can open the firewall open 23 ports, specific as follows:

Immediate effect, reboot disabled

Open: Service iptables start

OFF: Service iptables stop

Effective after reboot

Open: Chkconfig iptables on

Close: Chkconfig iptables off

When the firewall is turned on, make the following settings to open the relevant port

Modify the/etc/sysconfig/iptables file and add the following:

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 23-j ACCEPT

View Firewall iptables-l

------------------

NETSTAT-NUPL (Port of UDP type)
NETSTAT-NTPL (Port of TCP type)
You can use the lsof command to see if an end port is open. The view port can be used in this way, and I'll take port 80 as an example:
Lsof-i:80
If there is a display indicating that it has been opened, if there is no indication that the description is not open.


Reprint Address: http://hi.baidu.com/wlbing0625/item/fc3f8ec6b1f38dc2984aa096



how to turn on/off a specified port method through the Linux system iptables firewall

Typically, Iptables is already included in the Linux distribution.
Run Iptables--version to see if the system is installed Iptables

Start iptables
Service Iptables Start
Iptables--list//* view iptables rule set *//
Here's what iptables looks like when you don't have a plan defined:
Chain INPUT (Policy ACCEPT)
Target Prot opt source destination
Chain FORWARD (Policy ACCEPT)
Target Prot opt source destination
Chain OUTPUT (Policy ACCEPT)
Target Prot opt source destination

How to toggle the specified port on/off
For example:
Open Port 81:
Iptables-i input-i eth0-p TCP--dport 81-j ACCEPT
Iptables-i output-o eth0-p TCP--sport 81-j ACCEPT
Close Port 81:
Iptables-i input-i eth0-p TCP--dport 81-j DROP
Iptables-i output-o eth0-p TCP--sport 81-j DROP
and then save
/etc/rc.d/init.d/iptables Save

You can use the lsof command to see if an end port is open. View ports can be used in this way.
I'll take 81 ports for example:
lsof-i:81
If there are indications that the instructions have been opened. If there is no indication that there is no open reprint address: http://www.itokit.com/2012/0317/73346.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.