# 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