📄 00000009.htm
字号:
only send a single packet).
<BR>
<BR> Then we append (-A) to the `INPUT' chain, a rule specifying that for
<BR> packets from 127.0.0.1 (`-s 127.0.0.1') with protocol ICMP (`-p icmp') we
<BR> should jump to DROP (`-j DROP').
<BR>Lin here a <BR>Ma
<BR> Then we test our rule, using the second ping. There will be a pause <BR>before
<BR> the program gives up waiting for a response that will never come.
<BR>
<BR> We can delete the rule in one of two ways. Firstly, since we know that it
<BR>3.1is the only rule in the input chain, we can use a numbered delete, as in:
<BR>
<BR> # iptables -D INPUT 1
<BR> #
<BR>
<BR> To delete rule number 1 in the INPUT chain.
<BR>
<BR> The second way is to mirror the -A command, but replacing the -A with -D.
<BR> This is useful when you have a complex chain of rules and you don't want,
<BR> to have to count them to figure out that it's rule 37 that you want to <BR>get
<BR> rid of. In this case, we would use: e
<BR>
<BR> # iptables -D INPUT -s 127.0.0.1 -p icmp -j DROP <BR>on
<BR> #
<BR>
<BR> The syntax of -D must have exactly the same options as the -A (or -I or
<BR> -R) command. If there are multiple identical rules in the same chain, <BR>only
<BR> the first will be deleted.
<BR>
<BR>7.3 Filtering Specifications
<BR>
<BR> We have seen the use of `-p' to specify protocol, and `-s' to specify <BR>n
<BR> source address, but there are other options we can use to specify packet
<BR> characteristics. What follows is an exhaustive compendium.
<BR>
<BR> Specifying Source and Destination IP Addresses
<BR>
<BR> Source (`-s', `--source' or `--src') and destination (`-d',
<BR> `--destination' or `--dst') IP addresses can be specified in four ways.
<BR> The most common way is to use the full name, such as `localhost' or
<BR> `www.linuxhq.com'. The second way is to specify the IP address such as
<BR> `127.0.0.1'.
<BR>
<BR> The third and fourth ways allow specification of a group of IP addresses,
<BR> such as `199.95.207.0/24' or `199.95.207.0/255.255.255.0'. These both
<BR> specify any IP address from 199.95.207.0 to 199.95.207.255 inclusive; <BR>the
<BR>Lindigits after the `/' tell which parts of the IP address are significant.a <BR>Ma
<BR> `/32' or `/255.255.255.255' is the default (match all of the IP address).
<BR> To specify any IP address at all `/0' can be used, like so:
<BR>
<BR> [ NOTE: `-s 0/0' is redundant here. ]
<BR>3.1 # iptables -A INPUT -s 0/0 -j DROP
<BR> #
<BR>
<BR> This is rarely used, as the effect above is the same as not specifying <BR>the
<BR> `-s' option at all.
<BR>
<BR> Specifying Inversion
<BR>
<BR> Many flags, including the `-s' (or `--source') and `-d' (`--destination')
<BR> flags can have their arguments preceded by `!' (pronounced `not') to <BR>match
<BR> addresses NOT equal to the ones given. For example. `-s ! localhost' e
<BR> matches any packet not coming from localhost.
<BR> <BR>on
<BR> Specifying Protocol
<BR>
<BR> The protocol can be specified with the `-p' (or `--protocol') flag.
<BR> Protocol can be a number (if you know the numeric protocol values for IP)
<BR> or a name for the special cases of `TCP', `UDP' or `ICMP'. Case doesn't
<BR> matter, so `tcp' works as well as `TCP'.
<BR>
<BR> The protocol name can be prefixed by a `!', to invert it, such as `-p !
<BR> TCP' to specify packets which are not TCP. <BR>n
<BR>
<BR> Specifying an Interface
<BR>
<BR> The `-i' (or `--in-interface') and `-o' (or `--out-interface') options
<BR> specify the name of an interface to match. An interface is the physical
<BR> device the packet came in on (`-i') or is going out on (`-o'). You can <BR>use
<BR> the ifconfig command to list the interfaces which are `up' (i.e., working
<BR> at the moment).
<BR>
<BR> Packets traversing the INPUT chain don't have an output interface, so any
<BR> rule using `-o' in this chain will never match. Similarly, packets
<BR> traversing the OUTPUT chain don't have an input interface, so any rule
<BR> using `-i' in this chain will never match.
<BR> LinOnly packets traversing the FORWARD chain have both an input and output <BR>a Ma
<BR> interface.
<BR>
<BR> It is perfectly legal to specify an interface that currently does not
<BR> exist; the rule will not match anything until the interface comes up. <BR>This
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -