Iptables firewall settings

Source: Internet
Author: User
# Open DNS on this host and external DNS host interaction queries: use udpiptables-AOUTPUT-oeth0-pudp-s $ FW_IP -- sport53-dany/0 -- dport53-jACCEPTiptables-AINPUT-ieth0-pudp-sany/0 -- sport53-d $ FW_IP -- dport53-j

# Enable interaction between DNS on this host and external DNS host: use udp

Iptables-A output-o eth0-p udp-s $ FW_IP -- sport 53-d any/0 -- dport 53-j ACCEPT

Iptables-a input-I eth0-p udp-s any/0 -- sport 53-d $ FW_IP -- dport 53-j ACCEPT

# Enable interactive query between DNS on this host and external DNS host: use tcp

Iptables-a output-o eth0-p tcp-s $ FW_IP -- sport 53-d any/0 -- dport 53-j ACCEPT

Iptables-a input-I eth0-p tcp! -Y-s any/0 -- sport 53-d $ FW_IP -- dport 53-j ACCEPT

Open internal hosts to ssh to external hosts

Open the internal network and ssh can be used to connect to external hosts.

The procedure is as follows: (the default policy is DROP)

###-----------------------------------------------------###

# Open external host ssh port 22

###-----------------------------------------------------###

Iptables-a output-o eth0-p tcp-s $ FW_IP -- sport 1024: 65535-d any/0 -- dport 22-j ACCEPT

Iptables-a input-I eth0-p tcp! -- Syn-s any/0 -- sport 22-d $ FW_IP -- dport 1024: 65535-j ACCEPT

# The following are differences between ssh protocols:

Iptables-a output-o eth0-p tcp-s $ FW_IP -- sport 1020:1023-dany/0 -- dport 22-j ACCEPT

Iptables-a input-I eth0-p tcp! -- Syn-s any/0 -- sport 22-d $ FW_IP -- dport 1020:1023-j ACCEPT

Enable internal hosts to ftp to external hosts

Open the internal network and ftp to external hosts.

The procedure is as follows: (the default policy is DROP)

###-----------------------------------------------------###

# Open to external host ftp port 21

###-----------------------------------------------------###

# Open the command channel 21

Iptables-a output-o eth0-p tcp-s $ FW_IP -- sport 1024: 65535-d any/0 -- dport 21-j ACCEPT

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.