In Linux, you can set up uninterrupted running of iptables.

Source: Internet
Author: User
# Check whether the iptables command is/sbin/iptables [root @ test ~] # Whereisiptablesiptables:/sbin/iptables/usr/share/man/man8/iptables.8.gz # iptables has several default table tables, including filter, nat, and mangle # Initialize fil

# ConfirmIptablesWhether the command is/sbin/Iptables

[Root @ test ~] # Whereisiptables
Iptables:/sbin/iptables/usr/share/man/man8/iptables.8.gz

# Iptables has several default table tables, including filter, nat, and mangle.


# Initialize the INPUT, OUTPUT, and FORWARD chains of the filter table.


[Root @ test ~] #/Sbin/iptables-P INPUTACCEPT
[Root @ test ~] #/Sbin/iptables-P OUTPUT ACCEPT
[Root @ test ~] #/Sbin/iptables-P FORWARD ACCEPT

# Initialize nat tables PREROUTING, POSTROUTING, and OUTPUT chain to allow

[Root @ test ~] #/Sbin/iptables-t nat-P PREROUTING ACCEPT

[Root @ test ~] #/Sbin/iptables-t nat-P POSTROUTING ACCEPT

[Root @ test ~] #/Sbin/iptables-t nat-P OUTPUT ACCEPT

# Initialize the mangle table PREROUTING, INPUT, FORWARD, OUTPUT, and POSTROUTING chain to allow

[Root @ test ~] #/Sbin/iptables-t mangle-P PREROUTING ACCEPT

[Root @ test ~] #/Sbin/iptables-t mangle-P INPUT ACCEPT

[Root @ test ~] #/Sbin/iptables-t mangle-P FORWARD ACCEPT

[Root @ test ~] #/Sbin/iptables-t mangle-P OUTPUT ACCEPT

[Root @ test ~] #/Sbin/iptables-t mangle-P POSTROUTINGACCEPT

# Clear all filter rules & Custom Tables & traffic clearing
[Root @ test ~] #/Sbin/iptables-F
[Root @ test ~] #/Sbin/iptables? Z
[Root @ test ~] #/Sbin/iptables-X

# Clear all nat rules & Custom Tables & clear traffic
[Root @ test ~] #/Sbin/iptables-t nat-F
[Root @ test ~] #/Sbin/iptables-t nat? Z
[Root @ test ~] #/Sbin/iptables-t nat-X

# Clear all mangle rules & Custom Tables & traffic clearing

[Root @ test ~] #/Sbin/iptables-t mangle-F

[Root @ test ~] #/Sbin/iptables-t mangle? Z

[Root @ test ~] #/Sbin/iptables-t mangle-X

# Allow data similar to sending back. if this rule is not set, connection speed similar to ssh application is slow.
[Root @ test ~] #/Sbin/iptables-a input-m state -- stateESTABLISHED, RELATED-jACCEPT


# Allow all connections to the circular network card

[Root @ test ~] #/Sbin/iptables-a input-I lo-jACCEPT
# Allow port 22 connection

[Root @ test ~] #/Sbin/iptables-a input-p tcp -- dport 22-jACCEPT

# Allow ping

[Root @ test ~] #/Sbin/iptables-a input-p icmp -- icmp-type 8-jACCEPT
# The input chain is set to drop by default.

[Root @ test ~] #/Sbin/iptables-P INPUT DROP

# When using a remote host, open an ssh connection to check whether the connection is normal.

# Normally, you can connect to the server. if not, contact the administrator to restart the server.

# Save the configuration to the hard disk

/Etc/init. d/iptables save

# Viewing IP status

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.