have been modified by us at this time)
If the packet is in the native (that is, the destination IP of the packet is the network port IP of the native), the packet moves down the graph to reach the input chain . After the packet arrives in the input chain, any process will-receive it
Programs running on this machine can also send packets that go through the output chain and then reach the postroting chain output (note that this time the SRCIP of the packet may have been modified by us)
Syntax: iptables-Dchainrulenum [options] Where: chain indicates the chain, that is, the attribute rulenum such as INPUTFORWARD indicates the rule number. Start from 1. You can use iptables-LINPUT -- line-numbers to list... syntax: iptables-D chain rulenum [options] Where: chain indicates the chain, that is, the attribute rulenum such as input forward is the numbe
Explicit extensions: You must explicitly indicate which module to use for scaling to use the extended options
-M Extension Module name (This module should be available on both iptables and NetFilter)
1) multiport is used to match non-contiguous or continuous ports, and to specify 15 more ports
--sports "Port,port:port" specifies the source port
--dports Destination Port
The--ports source
from WAN only release response packets
$IPTABLES-A forward-i $INET _iface-o $LAN _iface-m State--state established,related-j ACCEPT
# Allow Ping packets from WAN to be delivered to all servers in the campus
$IPTABLES-A forward-p icmp-i $INET _iface-o $LAN _iface-d $LAN _http1_ip-j icmp_packets
$IPTABLES-A forward-p icmp-i $INET _iface-o $LAN _iface-d $LAN _http2
the local machine can also send data packets that pass throughOUTPUT chain,Then arrivePOSTROTING chain output(Note: The SrcIP of the data packet may have been modified)
If the data packet is to be forwarded (that is, the destination IP address is no longer in the current subnet), and the kernel allows forwarding, the data packet will move to the right.FORWARD chainAnd then arrivePOSTROUTING chain output(Select the network port of the corresponding subnet for sending)
When writing
For Linux users, Iptable is one of the necessary skills! Maybe with many people will feel iptables difficult, not familiar with! It feels like a mess! In fact iptables (firewall) is rarely a command how complicated. But you understand the logic of the relationship! The rest of the order is a bit of a rusty feeling! But all can understand what is doing!Iptables is
Relationship between iptables rules and between iptables rules
The relationship between iptables rules is ignored from top to bottom.Therefore, when adding rules, you must add them through files. In this way, you can control the order.Machine:[Root @ www ~] # Netstat-an | grep 6100Tcp 0 0 0.0.0.0: 6100 0.0.0.0: * LISTENTcp 0 0 192.168.5.140: 6100 192.168.4.199: 6
The firewall is divided into kernel State and user state:Iptables is a user-stateThe NetFilter is a kernel-stateIptables Integrated Language method:IPTABLES-T table name [ options ] link name condition -j ActionIptables-t raw/mangle/nat/filter-ai/-dfx/-lvn--line-numbers input/output/forward/preroting/postrouting conditions -j Drop/accept/reject/logPC Settings:/etc/init.d/iptables Stop # #清空所有规则, including default rulesIptables-i input-i lo-j ACCEPTIpt
,ack,rst SYN = =--syn--syn-p ICMP--icmp-type [num]num:0:echo-reply response message 8:echo-request Request message-p UDP--sport port--dport PORTShow Extensions:-M state--state combined with Ip_constack to track the status of the session New: Connection request established: Established connection invalid: Illegal connection Related: Associated, set specifically for FTP Exercise: 192.168.137.11 as a server, allowing only new data to be requested, and not allowing TCP/22 (80) to send new requests
#iptables [OPTION] COMMAND CHAIN match standard-j TARGET[OPTION]-T TABLENAME does not specify default to filter-j Specify targetCOMMANDManagement rules-a adds a rule at the end of the chain-I CHAIN [num] inserts the NUM rule on the China chain without specifying num to insert as first-D CHAIN [num] Delete the NUM rule on the CHAIN chain-R CHAIN [num] replaces the NUM rule on the CHAIN chainManagement chain-F [CHAIN] flush empties the specified rule ch
to display precise information );
-- The line-numbers rule displays the row number;
Matching Condition creteria:
Basic match:
-S SOURCE :( IP, NETWORK) or add! Indicates reverse (for example :! -S NETWORK); (it can be omitted to indicate multiple hosts)
-D DESTIONIP (target address );
-P {tcp | udp | icmp };
-I INTERFACE indicates the network INTERFACE from which the stream comes in. (only used for INPUT, FORWARD, POSTROUTING)
-O INTERFACE indicates the network card from which the stream is sen
→ Core Netfilter Configuration
Netfilter connection trackingsupport
"Layer7" match support
"String" match support
"Time" matchsupport
"Iprange" matchsupport
"Connlimit" matchsupport
"State" matchsupport
"Conntrack" connection match support
"Mac" address match support
"Multiport"
:--sport Destination Port--dport Source PortIcmp:--icmp-types8:echo Request Requests0:echo Reply AnswerExample: Open 172.16.37.1 ping response to native 172.16.37.10, and ping request; Note: If the default input/ouput is drop, the request and response are turned on to ping# iptables-a input-s 172.16.37.1-d 172.16.37.10-picmp--icmp-type 8-j ACCEPT# iptables-a output-s 172.16.37.10-d 172.16.37.1-picmp--icmp-t
Linux iptables ip address, Linux iptables shielding ip iptables is profound and profound. If you know the basic syntax and what else you need, check the information. Here are several Linux commands for shielding ip addresses, as shown below: command www.2cto.com iptables-I input-s 192.168.9.198-j DROP for blocking a si
Iptables and SOCKS5
From the article "Iptables and Natcheck", as long as at both ends of the use of iptables for NAT, even if both sides passed the Natcheck compatibility test, but the iptables on both sides can never cross each other.
How to do, one way is to add a transit server on the public network, both sides of
ACCEPT #允许22端口被外部访问- A input-j REJECT--reject-with icmp-host-prohibited-a forward-j REJECT--reject-with icmp-host-prohibited
# above two means to reject all other packets that do not conform to any of the above rules in the input and forward tables. and sends a host prohibited message to the rejected hosts.
COMMIT
2, iptables-a rule chain-I network interface-j the operation of the data
-A: Specifies the chain of rules that you want to add a rule to
(after the routed package should change the source address to 60.1.1.1, otherwise the package cannot be returned))[Root@xenserver-cukxsegi ~]# iptables-a forward-s 10.10.10.0/24-j ACCEPT #允许10.10.10.0/24 section of the Internet[Root@xenserver-cukxsegi ~]# iptables-a forward-s 10.100.100.0/24-j ACCEPT #允许10.100.100.0/24 section of the Internet[Root@xenserver-cukxsegi ~]#
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