: data packets with this feature are the data packets replied by the DNS server when the local machine queries DNS.
Example 4:
[Root @ edwin ~] # Iptables-a input-p tcp -- tcp-flags SYN, RST, ACKSYN-j ACCEPT
Function: SYN, RST, and ACK3 indicate that the SYN bit is 1, and the other two TCP packets with 0 are allowed. A packet that meets this characteristic is a packet that initiates a TCP connection.
Note: The "-- tcp-flags" sub-option is used to spec
-j ACCEPT
2) only accept data packets from the specified port service:
#iptables -D INPUT --dport 80 -j DROP
3) Allow forwarding of all data packets to the local 198.168.10.13) smtp server:
#iptables -A FORWARD -p tcp -d 198.168.10.13 --dport smtp -i eth0 -j ACCEPT
4) Allow forwarding of all udp data packets generated by software such as instant communication ):
#iptab
"table" to define and differentiate the different working functions and processing methods.We now use more than 3 different features:1.filter definition allows or does not allow2.nat defines the address translation3.mangle function: Modify message original dataFor filter generally can only be done on 3 chains: INPUT, FORWARD, OUTPUTIn general, Nat can only be done on 3 chains: Prerouting, OUTPUT, postroutingAnd Mangle is a 5 chain can do: prerouting,input,forward,output,postroutingIptables defi
. FUTURE REVISIONS OF THIS LICENSE
How to use this License for your documents ents
H. GNU General Public License
0. Preamble
1. terms and conditions for copying, DISTRIBUTION AND MODIFICATION
2. How to Apply These Terms to Your New Programs
I. sample script code
I .1. rc. firewall script code
I .2. rc. DMZ. firewall script code
I .3. rc. UTIN. firewall script code
I .4. rc. DHCP. firewall script code
I .5. rc. flush-iptables script code
I .6. rc.
PS: This iptables script is good, very practical, according to the actual application changes can be used by themselves. Share it for everyone to reference. Original author Anonymous. The source code is as follows:#!/bin/shmodprobe ipt_masquerademodprobe ip_conntrack_ftpmodprobe ip_nat_ftpiptables-fiptables-t nat-fiptables- Xiptables-t nat-x########################## #INPUT键 ################################## #ipt
MasqueradeTo automatically implement NAT when the system starts, add the end of the/etc/rc.d/rc.local file#echo "1" >/proc/sys/net/ipv4/ip_forward#/sbin/iptables-t nat-a postrouting-o Ppp0-j Masquerade2) SNAT: The general normal sharing of the Internet use this.All packets from the Eth0 (external network card) from the source address to 61.99.28.1 (a network segment specified here, generally can not be specified)
as 0 (all)PROTOCOL:TCP, UDP, ICMP, ICMPv6, Udplite,esp, ah, SCTP,Example: Deny 172.17.66.66 access to 172.17.88.88 TCP80 PortIptables-a forward-s 172.17.66.66-d 172.17.88.88-p tcp--dport 80-j REJECTDescription: [!] The explanation can be reversed. Example: In addition to 172.17.66.66 cannot ping this machine, others canIptables-a Inpput! -S 172.17.66.66-p icmp-j REJECT⑤[!]-I,--in-interface name: Packet inflow interface, only for data packet inflow, only for input, FORWARD, prerouting chain Exa
Iptables and stun
STUN Protocol (rfc3489, see http://www.ietf.org/rfc/rfc3489.txt) will be roughly divided into four types of NAT, namely full cone, restricted cone, port restricted cone and structured Ric. The following is an example (Example 1) to illustrate the differences between the four Nat methods:Machine A is on the private network (192.168.0.4)Nat server (210.21.12.140)Machine B is on the public network (210.15.27.166)Machine C is on the p
DNAT-J dnat -- to IP [-IP] [: Port-port] (NAT table's prerouting chain)Destination Address conversion. DNAT supports converting to a single IP address or an IP address pool.(A group of consecutive IP addresses)For example:Iptables-T Nat-A prerouting-I ppp0-P TCP -- dport 80/-J dnat -- To 192.168.0.1Change the destination address of the packet that comes in from ppp0 to 192.168.0.1.
Iptables-T Nat-A prerouting-I ppp0-P TCP -- dport 81/-J dnat -- To 19
--mac-source 00:0c:29:27:55:3f-j DROPDescription: A display match was called using the form "-M module keyword" in iptables. Here we use "-M mac–mac-source" to represent the source MAC address of the packet.11. Allow firewall native to open to TCP ports 20, 21, 25, 110, and Passive mode FTP port 1250-1280Iptables-a input-p tcp-m multiport--dport 20,21,25,110,1250:1280-j ACCEPTDescription: Use "-M
DROPiptables -P FORWARD ACCEPTiptables -P OUTPUT ACCEPTiptables -A INPUT -i lo -j ACCEPTiptables -A OUTPUT -o lo -j ACCEPTiptables -A INPUT -p tcp -m multiport --dports 25,80 -j ACCEPTiptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Note:
You can initialize iptables in the first three items.
Modprobe is the process of manually Loading modules. Generally, if you use service
, DISTRibution and Modification 2. How to Apply this Terms to Your the code I.1 for the New Programs I. Sample script. Rc.firewall script code I.2. Rc. Dmz.firewall script code I.3. Rc. Utin.firewall script code I.4. Rc. Dhcp.firewall script code I.5. Rc.flush-iptables script code I.6. Rc.test-iptables Script codeList of Tables3-1. Package 3-2 for local Target (which is our own machine). Local-source packag
2.1 Frame Diagram-->prerouting-->[route]-->forward-->postrouting--> mangle | mangle ^ mangle Nat| 2.1 frame Diagram-->prerouting-->[route]-->forward-->postrouting-->mangle | mangle ^ mangleNat | Filter | Nat| || |V |INPUT OUTPUT| mangle ^ mangle| Filter | NatV------>local------->| Filter2.2 Chains and tablesTableFilter: As the name implies, when used for filteringNat: As the name implies, when doing NATNat:network Address TranslatorChainINPUT: In the filter table, matching destination IP is the
= 255 time = 1.20 MS
64 bytes from 10.0.0.254: icmp_seq = 3 ttl = 255 time = 1.03 MS
64 bytes from 10.0.0.254: icmp_seq = 4 ttl = 255 time = 9.86 MS
[8] + Stopped ping 10.0.0.254
5.5 IPTABLES settings:
5.5.1 edit scripts
Command: [root @ off-proxy/] # chmod 755/etc/rc. d/firewall. sh (modify the file attribute of firewall)
Command: [root @ off-proxy/] # vi/etc/rc. d/firewall. sh (use the vi command to open the firewall file for editing)
-to Apply this 2. to TERMS The code for the New Programs i. Sample script i.1. rc.firewall script code i.2. RC. Dmz.firewall script code i.3. RC. Utin.firewall script code i.4. RC. Dhcp.firewall script code i.5. rc.flush-iptables script code i.6. rc.test-iptables script codeList of Tables3-1. Package 3-2 for local Target (which is our own machine). Local-source package 3-3. The packet forwarded 4-1. The pac
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.