Iptables 1.4.7 practical application

Source: Internet
Author: User

As needed, the following ports can be accessed from the Internet: 80, 14490, 14500, 14460, 14470, and 24461
External ports accessible to the server: 80 and 25
Considering the remote management interface, add port 22 and allow port 53 for Internet access. Allow loop back interface, icmp ping.
 
The specific configuration information is as follows: www.2cto.com
[Root @ localhost sysconfig] # iptables-V
Iptables v1.4.7
[Root @ localhost sysconfig] # iptables-S
-P INPUT DROP
-P FORWARD ACCEPT
-P OUTPUT DROP
-A input-I lo-j ACCEPT
-A input-m state -- state RELATED, ESTABLISHED-j ACCEPT
-A input-p tcp-m state -- state NEW-m tcp -- dport 22-j ACCEPT
-A input-p tcp-m state -- state NEW-m multiport -- dports 80, 14490, 14500,14460, 14470,24461-j ACCEP
-A input-p udp-m state -- state NEW-m multiport -- dports 14490,14500, 14460,14470, 24461-j ACCEPT
-A input-p icmp-m icmp -- icmp-type 8-j ACCEPT
-A input-p icmp-m icmp -- icmp-type 0-j ACCEPT
-A output-p icmp-j ACCEPT
-A output-o lo-j ACCEPT
-A output-m state -- state RELATED, ESTABLISHED-j ACCEPT
-A output-p tcp-m state -- state NEW-m tcp -- sport 22-j ACCEPT
-A output-p tcp-m state -- state NEW-m multiport -- dports 80, 25-j ACCEPT
-A output-p tcp-m state -- state NEW-m tcp -- dport 53-j ACCEPT
-A output-p udp-m state -- state NEW-m udp -- dport 53-j ACCEPT
-A output-p icmp-m icmp -- icmp-type 8-j ACCEPT
-A output-p icmp-m icmp -- icmp-type 0-j ACCEPT
 
Situations encountered in the process:
1. The domain name cannot be pinged. The problem was also found before, but there was no time for verification.
When output drop is found, you cannot telnet the dns port 53. Add entry:
-A output-p tcp-m state -- state NEW-m tcp -- dport 53-j ACCEPT
-A output-p udp-m state -- state NEW-m udp -- dport 53-j ACCEPT
Tcp and udp ports are included.
 
An error occurred while writing.
-A output-p udp-m state -- state NEW-m tcp -- dport 53-j ACCEPT
The entry is written incorrectly. The Protocol does not match the preceding and following parameters. However, when iptables is restarted, the last line of "COMMIT" error is reported. Sadly, you have to take it seriously!
 
2.-a input-m state -- state RELATED, ESTABLISHED-j ACCEPT
The entries here allow subsequent links that have established connections. You need to add them.
 
3.-a input-p tcp-m state -- state NEW-m tcp -- dport 22-j ACCEPT
Allow new connection
 
4. INPUT and OUTPUT can be separated in writing. Easy to view and troubleshoot.
 
5. restart: service iptables restart
Save: iptable-save>/etc/sysconfig/iptables
 
6. Some interfaces are allowed to be switched back.
-A input-I lo-j ACCEPT
-A output-o lo-j ACCEPT
 
7. Allow icmp
-A input-p icmp-m icmp -- icmp-type 8-j ACCEPT
-A input-p icmp-m icmp -- icmp-type 0-j ACCEPT
-A output-p icmp-m icmp -- icmp-type 8-j ACCEPT
-A output-p icmp-m icmp -- icmp-type 0-j ACCEPT
 
 
 
 
From the c371193852 blog

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.