.org-j ACCEPT
Iptables-A Filter-d img.cn99.com-j ACCEPT
Iptables-A Filter-j DROP
Open some ports of an IP address, and other ports are closed
Iptables-A Filter-p tcp -- dport 80-s 192.168.100.200-d www.pconline.com.cn-j ACCEPT
Iptables-A Filter-p tcp -- dport 25-s 192.168.100.200-j ACCEPT
be compared to a single port or a range, for example, -- sport 22: 80, indicating that the port from 22 to 80 is qualified, to compare multiple non-consecutive ports, you must use the -- multiport parameter. For more information, see the following section. You can use it when comparing the port number! The operator performs reverse comparison.
Parameter -- dport, -- destination-port
Example iptables-a inpu
used to match the packet can match a single port or a range, for example:? Sport 22: 80It indicates that ports 22 to 80 are both qualified. if you want to match multiple discontinuous ports, you must use? For more information about multiport parameters, see the following section. You can use it when matching the port number! Operator for reverse matching. Parameter? Dport ,? Destination-portExample iptables
makes a reverse alignment, for example:-S! 192.168.0.0/24.Parameter-D,--DST,--destinationExample Iptables-a input-d 192.168.1.1Description used to compare the destination IP of the packet, set the same way.Parameter-I.,--in-interfaceExample Iptables-a input-i eth0The description is used to match the packet from which card to enter, you can use the wildcard character + to enlarge the range ratio, for exampl
write to multiple discrete ports or multiple sets of contiguous ports, the maximum limit of 15 sets of ports, each port range occupies two ports; Protocols that can be supported: TCP, UDP, Udplite, DCCP, SCTP. Related options: [!]--source-ports,--Sports Port[,port|,port:port] ... [!] --destination-ports,--dports Port[,port|,port:port] ... [!] --ports Port[,port|,port:port] ...--dports 22,80,3306-j ACCEPT Exam
eth + indicates all ethernet network cards. You can also use it! The operator performs reverse comparison, for example,-I! Eth0.Parameter-o, -- out-interfaceExample iptables-a forward-o eth0Specifies the network card from which the packet is sent.Parameter -- sport, -- source-portExample iptables-a input-p tcp -- sport 22It indicates that the source port number of the packet can be compared to a single por
pass. You can use the-FRAGMENT/-F option to specify the second and subsequent IP fragments to resolve the above problem.#iptables-A forward-f-S 192.168.1.0/24-d 192.168.2.100-j ACCEPTNote There are now many instances of IP fragmentation attacks, such as Dos attacks, so allowing IP fragmentation to pass is a security risk, which can be limited by iptables matching extensions.Set the rule match for the exten
continuous set of IP addresses)
For example:
Iptables-t nat-a prerouting-i ppp0-p TCP--dport 80/
-j Dnat--to 192.168.0.1
Change the destination address of the packet to access TCP/80 from Ppp0 to 192.168.0.1
Iptables-t nat-a prerouting-i ppp0-p TCP--dport 81/
-j Dnat--to 192.168.0.2:80
Iptables-t nat-a prerouting-i ppp0-p TCP--dport 80/
-j Dnat--to 192.168.0.1
action is ignored)1, multi-port matching.1) match multiple source ports.#iptables-A input-p tcp-m multiport–sport 22,53,80,1102) match multiple destination ports.#iptables-A input-p tcp-m multiport–dpoort 22,53,803) matching multiport (either source port or destination port
bm | kmp specifies the algorithm bm or kmp.-- String "STRING" specifies the string itself
Iptables-A input-p tcp-m multiport -- dports110, 80, 25, 445,1863, 5222-j ACCEPTIptables-a input-p tcp-s 172.16.0.0/16 -- dport 139-jACCEPT# Allow dns resolution. if a DNS server (forwarder) is configured on the intranet, only the IP address of the forwarder can be used. modify the ip address (-s IP address) on your o
, and multiport...
Target (Common Action ):
Target descriptionAcceptDrop dropped data packetsReturn directly without comparisonThe application that the queue sends to the user-space to process the data packet.Snat nat: Translation Source AddressDnat nat: Translation addressDedicated for masquerade NAT: Translation source address becomes Nic MacDedicated for redirect NAT: A port transferred to the Local Machine
Use/etc/rc. d/init. d/
)Num Target prot opt source destinationChain FORWARD (Policy ACCEPT)Num Target prot opt source destinationChain OUTPUT (Policy ACCEPT)Num Target prot opt source destinationYou can see that the rule has been deleted.5. Prohibit a network segment from accessing my eth0 network card, such as 10.10.10.0/24[Email protected] ~]# iptables-a input-i eth0-s 10.10.10.0/24-j DROP[Email protected] ~]# iptables-l-NChain
custom empty chain.
⑤ Use of extension options
Eg: for http service requests, the connection status of the 192.168.5.1 server segment is controlled.
Iptables-a input-d 192.168.5.1-p tcp-dport 80-m state-state NEW, ESTABLISHED-j ACCEPT
Iptables-a output-s 192.168.5.1-p tcp-sport 80-m state-state ESTABLISHED-j ACCEPT
// The server responds to the NEW and ESTABLISHED packets of the INPUT server. The OUTPUTo
used to compare the packets. It can be compared to a single port or a range, for example, -- sport 22: 80, which indicates that the port number ranges from 22 to 80.
Ports are both qualified. To compare multiple ports that are not consecutive, you must use the -- multiport parameter. For details, see the following section. You can use it when comparing the port number!
The operator performs reverse comparison.
Parameter -- dport, -- destination-port
to 80 are qualified. To compare multiple ports that are not consecutive, you must use the -- multiport parameter. For details, see the following section. You can use it when comparing the port number! The operator performs reverse comparison. Parameter -- dport, -- destination-port example iptables-a input-p tcp -- dport 22 indicates the destination port number used to compare the packets. The setting meth
iptables-a input-d 192.168.1.1Description used to compare the destination IP address of the packet. the setting method is the same as above.
Parameter-I, -- in-interfaceExample iptables-a input-I eth0The description is used to compare the network card from which the package Enters. you can use wildcard character + to perform large-scale comparison. for example,-I eth + indicates all ethernet network cards.
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.