NAME
iptables - IPv4 기반 패킷 필터링 및 NAT 를 위한 관리자 툴SYNOPSIS
iptables [-t table] -[AD] chain rule-specification [options]iptables [-t table] -I chain [rulenum] rule-specification [options]
iptables [-t table] -R chain rulenum rule-specification [options]
iptables [-t table] -D chain rulenum [options]
iptables [-t table] -[LFZ] [chain] [options]
iptables [-t table] -N chain
iptables [-t table] -X [chain]
iptables [-t table] -P chain target [options]
iptables [-t table] -E old-chain-name new-chain-name
DESCRIPTION
Iptables 은 리눅스 커널에 있는 IP 패킷 필터 규칙 테이블을 셋업하고, 관리하고, 조사하는 데 사용된다. 여러 다른 테이블들이 정의될 수 있다. 각 테이블은 많은 내장 체인들을 갖고 있으며 사용자-정의 체인들을 갖고 있을 수도 있다.각 체인은 패킷과 비교할 수 있는 규칙들의 리스트이다. 각 규칙은 비교해서 일치하는 패킷을 어떻게 할 것인가를 지정한다. 이것은 `타겟'이라고 불리며 이것은 동일한 테이블에 있는 사용자-정의 체인으로 점프할 수도 있다.
TARGETS
방화벽 규칙은 어떤 패킷, 그리고 어떤 타겟에 대한 판단 기준을 지정한다. 그 패킷이 비교해서 일치하지 않으면 그 체인에 있는 다음 규칙이 시험된다; 또 일치한다면 타켓의 값과 동일한 그 다음의 규칙이 검사된다. 그 값은 사용자-정의 체인의 이름이거나 아래 열거된 것과 같은 특수 값들 중 하나가 될 수 있다.- ACCEPT
- 은 패킷이 통과하는 것을 의미한다.
- DROP
- 은 패킷이 통과하지 못한다는 것을 의미한다.
- QUEUE
- 은 패킷을 사용자 공간(userspace; 커널이 지원하는 경우)에 전달하는 것을 의미한다.
- RETURN
- 은 이 체인을 더이상 지나가지 못하도록 하고 이전에 (호출한) 체인 내 다음 규칙으로 복귀하도록 하는 것을 의미한다. 내장 체인의 끝에 도달하거나 내장 체인에 있는 어떤 규칙이 타겟과 일치하는 경우, 그 체인 정책에 의해서 지정된 타겟이 그 패킷의 운명을 결정한다.
TABLES
현재 3개의 독립 테이블들이 있다(어떤 테이블들이 존재하는가는 커널의 설정 옵션들과 어떤 모듈들이 존재하는가에 따라 다르다).- -t, --table table
-
이 옵셩은 명령이 동작해야 하는 패킷 비교 테이블을 지정한다.
커널이 자동 모듈 로딩 옵션을 가지도록 설정되었다면,
없는 테이블을 위한 적절한 모듈을 로딩하려는 시도가 이루어질 것이다.
테이블은 다음과 같다:
-
- filter:
- 이것은 디폴트 테이블(만일 -t 옵션이 주어지지 않으면 사용된다)이다. 이것은 다음과 같은 내장 체인들을 갖고 있다. INPUT (리눅스 박스 자신에게 들어온 패킷들을 위한 것), FORWARD (리눅스 박스를 통과해서 라우팅될 패킷들을 위한 것), 그리고 OUTPUT (리눅스 박스 내부에서 생성된 패킷들을 위한 것).
- nat:
- 이 테이블은 새로운 커넥션을 만드는 패킷이 도달할 때 사용된다. 이것은 다음과 같은 3개의 내장들로 구성된다: PREROUTING (패킷들이 들어오자마자 바꾸기 위한), OUTPUT (라우팅하기 전에 내부에서 생성된 패킷들을 바꾸기 위한), 그리고 POSTROUTING (패킷들이 나가기 직전에 바꾸기 위한).
- mangle:
- 이 테이블은 특별한 패킷 변경을 위해서 사용된다. 커널 2.4.17까지 이것은 다음 2개의 내장 체인들을 가지고 있었다: This table is used for specialized packet alteration. Until kernel PREROUTING (라우팅 하기 전 들어오는 패킷들을 바꾸기 위한) 그리고 OUTPUT (라우팅 하기 전 내부적으로 생성된 패킷들을 바꾸기 위한). 커널 2.4.18 부터는 다음 세개의 다른 내장 체인들도 지원되었다: INPUT (박스 내부로 스스로 들어오는 패킷들을 위한), FORWARD (박스를 통해 라우팅 되고 있는 패킷들을 바꾸기 위한),그리고 POSTROUTING (막 나가려고 하는 패킷들을 바꾸기 위한).
OPTIONS
iptables 에 의해 인식되는 이 옵션들은 몇개의 다른 그룹들로 나뉘어 질 수 있다.COMMANDS
아래의 옵션들은 실행해야 할 특정한 활동을 지정한다. 아래에 별도로 지정되어 있지 않는 한, 이들 중 단 하나만이 실행라인에서 지정될 수 있다. 모든 명령이나 옵션이름들의 긴 버젼들에 대해, 당신은 오직 iptables 가 다른 모든 옵션들로부터 차별화될 수 있다는 것을 확실히 하기에 충분한 문자들 만을 사용해야 할 것이다. (한마디로, 다른 옵션과 차별될 수 있는 문자만으로 iptable 명령어는 해당옵션 인식이 가능하다는 것이다.)- -A, --append chain rule-specification
- 선택된 체인의 마지막에 하나 이상의 규칙들을 추가한다. 출발지 와/또는 목적지 이름들을 하나 이상의 주소로 분해할 때, 각각의 가능한 주소 조합에 하나의 규칙이 추가될 것이다.
- -D, --delete chain rule-specification
-
- -D, --delete chain rulenum
- 선택된 체인의 하나 이상의 규칙들을 삭제한다. 이 명령에는 두가지 종류의 버젼이 있다: 규칙은 체인 내의 숫자로(첫번째 규칙이 1부터 시작된다) 또는 매치되는 규칙으로 지정될 수 있다.
- -I, --insert chain [rulenum] rule-specification
- 선택된 체인 내에 주어진 Rule Number 의 형태로 하나 이상의 규칙을 삽입한다. 그러므로 Rule Number 가 1이면, 하나의 규칙 또는 여러개의 규칙이 체인의 앞머리에 삽입된다. 이것 또한 Rule Number 가 지정되지 않는 경우 Default값이 된다.
- -R, --replace chain rulenum rule-specification
- 선택된 체인 내의 규칙을 교체한다. 출발지 와/또는 도착지 이름들이 여러개의 주소들로 분해되면, 명령이 실패된다. 규칙들은 Rule Number 1부터 지정된다.
- -L, --list [chain]
-
선택된 체인의 모든 규칙들을 나열한다. 만일 어떤 체인도 선택되지 않으면, 모든 체인의 규칙이 나열된다. 모든 다른
iptables 명령들과 같이, 이는 지정된 테이블(필터는 Default)을 적용한다. 그러므로 NAT 규칙들을 받아보기 위해서는
iptables -t nat -n -L
긴 역행 DNS 검색을 피하는 대신에 -n 옵션이 자주 사용되는 것에 대해 유의하라. -Z (zero) 옵션을 지정하는 것과 마찬가지로 정석적이다. 이러한 경우 체인들은 원자적으로 나열되고 원점으로 맞추어질 것이다. 정확한 결과는 다른 주어진 변수들에 의해 영향을 받는다. 정확한 규칙들은 당신이iptables -L -v
를 사용하기 전까지 막혀있게 된다. - -F, --flush [chain]
- 선택된 체인을 쏟아 흘러내리게 한다. (아무것도 주어지지 않은 경우엔 테이블 내의 모든 체인이 선택된다). 이것은 모든 규칙들을 하나하나 지워나가는 것과 동등하다.
- -Z, --zero [chain]
- 모든 체인들 내의 패킷과 바이트 카운터들을 원점화한다. 이것은 카운터들이 지워지기 전에 즉시 볼 수 있게(앞을 참고) 하기 위해서 -L, --list (list) 옵션을 지정하는 것과 마찬가지로 정석적이다.
- -N, --new-chain chain
- 새로운 사용자 정의 체인을 주어진 이름으로 생성한다. 그 이름에 대해 어떠한 타겟도 미리 존재해서는 안된다.
- -X, --delete-chain [chain]
- 지정된 임의의 사용자 정의 체인을 지운다. 여기에는 어떠한 참조도 있으면 안된다. 만일 그렇지 않다면, 해당 체인이 지워지기 전에 참조된 규칙을 먼저 지워야만 한다. 만약 아무런 인자도 주어지지 않는다면, 그것은 임의로 테이블 내의 초기 정의된 것이 아닌 모든 체인들을 지울 것이다.
- -P, --policy chain target
- 해당 체인에 대해 주어진 타겟으로의 정책을 맞춘다. 합당한 테겟에 대해서는 섹션 TARGETS 을 본다. 오직 초기 정의 체인들 (맨 처음부터 정의되어있던 : 사용자 정의가 아닌) 만이 정책들을 가질 수 있고, 초기 정의 체인들과 사용자 정의 체인들 모두 정책 타겟으로는 될 수 없다.
- -E, --rename-chain old-chain new-chain
- 사용자 정의의 체인을 새로 주는 이름으로 바꾼다. 이것은 표면적이며, 테이블의 구조에는 전혀 영향을 끼치지 않는다.
- -h
- 도움말. 명령 문법에 대한 (일반적으로 가장 간단한) 설명을 준다.
PARAMETERS
아래의 파라미터들은 규칙 설명서를 구성한다. (add, delete, insert, replace, append 명령들에서 사용되었던 것처럼)- -p, --protocol [!] protocol
- 체크할 룰이나 패킷의 프로토콜이다. 프로토콜은 tcp, udp, icmp, 또는 or all, 또는 이들 프로토콜을 나타내는 숫자로 프로토콜을 지정할 수 있다. /etc/protocols의 프로토콜 이름도 가능하다. 프로토콜 앞의 "!" 는 해당 프로토콜을 제외한 나머지를 가리킨다. 숫자 영(0)은 all. 과 같다. 프로토콜 all 은 모든 프로토콜을 나타내며 -p 옵션이 생략되었을 때 기본으로 사용된다.
- -s, --source [!] address[/mask]
- 소스 설정. Address 는 네트워크 이름, 호스트 이름(DNS와 같은 원격 쿼리로 정해진 이름을 지정하는 하는 것은 좋지 않다), 네트워크 IP 주소(/마스크 옵션 가능), 또는 일반 IP 주소를 설정할 수 있다. 마스크는 네트쿼크 마스크나 네트워크 마스크의 왼쪽 끝부터 1로 마스크한 10진수 값일 수 있다. 즉 마스크 24 는 255.255.255.0. 와 같다. 주소 앞의 "!" 는 해당 주소를 제외한 다른 주소를 나타낸다. 플래그 --src 은 이 옵션의 별칭이다.
- -d, --destination [!] address[/mask]
- 목적지 설정 이 설정의 자세한 사항은 -s (source) 을 참조한다. 이 옵션은 --dst 을 별칭으로 사용한다.
- -j, --jump target
- 이 옵션은 룰의 대상(target)을 지정한다. 패킷이 룰과 일치할 경우의 행동을 정할 수 있다. 대상은 사용자 정의 체인(이 룰이 정의된 테이블의)이거나 바로 패킷의 운명을 결정지을 내장 체인 또는 extension (아래의 EXTENSIONS 참조). 룰에서 이 옵션이 생략되면 이 룰은 패킷에는 아무런 역할도 하지 않지만 룰의 숫자는 늘어난다.
- -i, --in-interface [!] 이름
- 패킷을 받을 인터페이스 이름이다. (단, 패킷이 INPUT, FORWARD PREROUTING 체인 중의 하나에 들어있어야 한다). 인터페이스 이름 앞에 "!" 이 있으면 그 결과를 뒤집는다. 인터페이스 이름이 "+"로 끝나면 그것으로 시작하는 모든 인터페이스를 나타낸다. 옵션을 생략할 경우 모든 인터페이스 이름이 매칭된다.
- -o, --out-interface [!] 이름
- 패킷이 보내질 인터페이스 이름을 지정한다. ( FORWARD, OUTPUT POSTROUTING 체인에 들어온 패킷에 대해서만). 인터페이스 이름 앞에 "!" 이 있으면 그 결과를 뒤집는다. 인터페이스 이름이 "+"로 끝나면 그것으로 시작하는 모든 인터페이스를 나타낸다. 옵션을 생략할 경우 모든 인터페이스 이름이 매칭된다.
- [!] -f, --fragment
- 이 옵션은 쪼개진 패킷에서 헤드 패킷을 제외한 나머지 패킷에만 룰을 적용한다. 출발지와 목적지를 구분할 수 없는 패킷(또는 ICMP 타입)은 걸러낼 수 있는 룰이 존재하지 않는다. -f 플래그 앞에 "!" 이 붙으면 헤드 패킷이나 쪼개지지 않은 패킷에만 적용된다.
- -c, --set-counters PKTS BYTES
- 이 옵션으로 패킷이나 룰의 바이트 카운터를 볼 수 있다. ( INSERT, APPEND, REPLACE 연산 중에).
OTHER 옵션S
The following additional 옵션s can be specified:- -v, --verbose
- Verbose output. This 옵션 makes the list 명령 show the interface 이름, the rule 옵션s (if any), and the TOS masks. The packet and byte counters are also listed, with the suffix 'K', 'M' or 'G' for 1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see the -x flag to change this). For appending, insertion, deletion and replacement, this causes detailed information on the rule or rules to be printed.
- -n, --numeric
- Numeric output. IP addresses and port numbers will be printed in numeric format. By default, the program will try to display them as host 이름s, network 이름s, or services (whenever applicable).
- -x, --exact
- Expand numbers. Display the exact value of the packet and byte counters, instead of only the rounded number in K's (multiples of 1000) M's (multiples of 1000K) or G's (multiples of 1000M). This 옵션 is only relevant for the -L 명령.
- --line-numbers
- When listing rules, add line numbers to the beginning of each rule, corresponding to that rule's position in the chain.
- --modprobe=명령
- When adding or inserting rules into a chain, use 명령 to load any necessary modules (targets, match 확장s, etc).
MATCH 확장S
iptables can use extended packet matching modules. These are loaded in two ways: implicitly, when -p or --protocol is specified, or with the -m or --match 옵션s, followed by the matching module 이름; after these, various extra 명령 line 옵션s become available, depending on the specific module. You can specify multiple extended match modules in one line, and you can use the -h or --help 옵션s after the module has been specified to receive help specific to that module.The following are included in the base package, and most of these can be preceded by a ! to invert the sense of the match.
ah
This module matches the SPIs in AH header of IPSec packets.- --ahspi [!] spi[:spi]
-
conntrack
This module, when combined with connection tracking, allows access to more connection tracking information than the "state" match. (this module is present only if iptables was compiled under a kernel supporting this feature)- --ctstate state
- Where state is a comma separated list of the connection states to match. Possible states are INVALID meaning that the packet is associated with no known connection, ESTABLISHED meaning that the packet is associated with a connection which has seen packets in both directions, NEW meaning that the packet has started a new connection, or otherwise associated with a connection which has not seen packets in both directions, and RELATED meaning that the packet is starting a new connection, but is associated with an existing connection, such as an FTP data transfer, or an ICMP 에러. SNAT A virtual state, matching if the original source address differs from the reply destination. DNAT A virtual state, matching if the original destination differs from the reply source.
- --ctproto proto
- Protocol to match (by number or 이름)
- --ctorigsrc [!] address[/mask]
- Match against original source address
- --ctorigdst [!] address[/mask]
- Match against original destination address
- --ctreplsrc [!] address[/mask]
- Match against reply source address
- --ctrepldst [!] address[/mask]
- Match against reply destination address
- --ctstatus [NONE|EXPECTED|SEEN_REPLY|ASSURED][,...]
- Match against internal conntrack states
- --ctexpire time[:time]
- Match remaining lifetime in seconds against given value or range of values (inclusive)
dscp
This module matches the 6 bit DSCP field within the TOS field in the IP header. DSCP has superseded TOS within the IETF.- --dscp value
- Match against a numeric (decimal or hex) value [0-32].
- --dscp-class DiffServ Class
- Match the DiffServ class. This value may be any of the BE, EF, AFxx or CSx classes. It will then be converted into it's according numeric value.
esp
This module matches the SPIs in ESP header of IPSec packets.- --espspi [!] spi[:spi]
-
helper
This module matches packets related to a specific conntrack-helper.- --helper string
-
Matches packets related to the specified conntrack-helper.
-
string can be "ftp" for packets related to a ftp-session on default port. For other ports append -portnr to the value, ie. "ftp-2121".
Same rules apply for other conntrack-helpers.
icmp
This 확장 is loaded if `--protocol icmp' is specified. It provides the following 옵션:- --icmp-type [!] type이름
-
This allows specification of the ICMP type, which can be a numeric
ICMP type, or one of the ICMP type 이름s shown by the 명령
iptables -p icmp -h
length
This module matches the length of a packet against a specific value or range of values.- --length length[:length]
-
limit
This module matches at a limited rate using a token bucket filter. A rule using this 확장 will match until this limit is reached (unless the `!' flag is used). It can be used in combination with the LOG target to give limited logging, for 예.- --limit rate
- Maximum average matching rate: specified as a number, with an 옵션al `/second', `/minute', `/hour', or `/day' suffix; the default is 3/hour.
- --limit-burst number
- Maximum initial number of packets to match: this number gets recharged by one every time the limit specified above is not reached, up to this number; the default is 5.
mac
- --mac-source [!] address
- Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX. 주의 that this only makes sense for packets coming from an Ethernet device and entering the PREROUTING, FORWARD or INPUT chains.
mark
This module matches the netfilter mark field associated with a packet (which can be set using the MARK target below).- --mark value[/mask]
- Matches packets with the given unsigned mark value (if a mask is specified, this is logically ANDed with the mask before the comparison).
multiport
This module matches a set of source or destination ports. Up to 15 ports can be specified. It can only be used in conjunction with -p tcp or -p udp.- --source-ports port[,port[,port...]]
- Match if the source port is one of the given ports. The flag --sports is a convenient alias for this 옵션.
- --destination-ports port[,port[,port...]]
- Match if the destination port is one of the given ports. The flag --dports is a convenient alias for this 옵션.
- --ports port[,port[,port...]]
- Match if the both the source and destination ports are equal to each other and to one of the given ports.
owner
This module attempts to match various characteristics of the packet creator, for locally-generated packets. It is only valid in the OUTPUT chain, and even this some packets (such as ICMP ping responses) may have no owner, and hence never match.- --uid-owner userid
- Matches if the packet was created by a process with the given effective user id.
- --gid-owner groupid
- Matches if the packet was created by a process with the given effective group id.
- --pid-owner processid
- Matches if the packet was created by a process with the given process id.
- --sid-owner sessionid
- Matches if the packet was created by a process in the given session group.
- --cmd-owner 이름
- Matches if the packet was created by a process with the given 명령 이름. (this 옵션 is present only if iptables was compiled under a kernel supporting this feature)
physdev
This module matches on the bridge port input and output devices enslaved to a bridge device. This module is a part of the infrastructure that enables a transparent bridging IP firewall and is only useful for kernel 버젼s above 버젼 2.5.44.- --physdev-in 이름
- 이름 of a bridge port via which a packet is received (only for packets entering the INPUT, FORWARD and PREROUTING chains). If the interface 이름 ends in a "+", then any interface which begins with this 이름 will match. If the packet didn't arrive through a bridge device, this packet won't match this 옵션, unless '!' is used.
- --physdev-out 이름
- 이름 of a bridge port via which a packet is going to be sent (for packets entering the FORWARD, OUTPUT and POSTROUTING chains). If the interface 이름 ends in a "+", then any interface which begins with this 이름 will match. 주의 that in the nat and mangle OUTPUT chains one cannot match on the bridge output port, however one can in the filter OUTPUT chain. If the packet won't leave by a bridge device or it is yet unknown what the output device will be, then the packet won't match this 옵션, unless
- --physdev-is-in
- Matches if the packet has entered through a bridge interface.
- --physdev-is-out
- Matches if the packet will leave through a bridge interface.
- --physdev-is-bridged
- Matches if the packet is being bridged and therefore is not being routed. This is only useful in the FORWARD and POSTROUTING chains.
pkttype
This module matches the link-layer packet type.- --pkt-type [unicast|broadcast|multicast]
-
state
This module, when combined with connection tracking, allows access to the connection tracking state for this packet.- --state state
- Where state is a comma separated list of the connection states to match. Possible states are INVALID meaning that the packet could not be identified for some reason which includes running out of memory and ICMP 에러s which don't correspond to any known connection, ESTABLISHED meaning that the packet is associated with a connection which has seen packets in both directions, NEW meaning that the packet has started a new connection, or otherwise associated with a connection which has not seen packets in both directions, and RELATED meaning that the packet is starting a new connection, but is associated with an existing connection, such as an FTP data transfer, or an ICMP 에러.
tcp
These 확장s are loaded if `--protocol tcp' is specified. It provides the following 옵션s:- --source-port [!] port[:port]
- Source port or port range specification. This can either be a service 이름 or a port number. An inclusive range can also be specified, using the format port:port. If the first port is omitted, "0" is assumed; if the last is omitted, "65535" is assumed. If the second port greater then the first they will be swapped. The flag --sport is a convenient alias for this 옵션.
- --destination-port [!] port[:port]
- Destination port or port range specification. The flag --dport is a convenient alias for this 옵션.
- --tcp-플래그 [!] mask comp
-
Match when the TCP 플래그 are as specified. The first argument is the
플래그 which we should examine, written as a comma-separated list, and
the second argument is a comma-separated list of 플래그 which must be
set. 플래그 are:
SYN ACK FIN RST URG PSH ALL NONE.
Hence the 명령
iptables -A FORWARD -p tcp --tcp-플래그 SYN,ACK,FIN,RST SYN
will only match packets with the SYN flag set, and the ACK, FIN and RST 플래그 unset. - [!] --syn
- Only match TCP packets with the SYN bit set and the ACK and RST bits cleared. Such packets are used to request TCP connection initiation; for 예, blocking such packets coming in an interface will prevent incoming TCP connections, but outgoing TCP connections will be unaffected. It is equivalent to --tcp-플래그 SYN,RST,ACK SYN. If the "!" flag precedes the "--syn", the sense of the 옵션 is inverted.
- --tcp-옵션 [!] number
- Match if TCP 옵션 set.
- --mss value[:value]
- Match TCP SYN or SYN/ACK packets with the specified MSS value (or range), which control the maximum packet size for that connection.
tos
This module matches the 8 bits of Type of Service field in the IP header (ie. including the precedence bits).- --tos tos
-
The argument is either a standard 이름, (use
iptables -m tos -h
to see the list), or a numeric value to match.
ttl
This module matches the time to live field in the IP header.- --ttl ttl
- Matches the given TTL value.
udp
These 확장s are loaded if `--protocol udp' is specified. It provides the following 옵션s:- --source-port [!] port[:port]
- Source port or port range specification. See the 설명 of the --source-port 옵션 of the TCP 확장 for details.
- --destination-port [!] port[:port]
- Destination port or port range specification. See the 설명 of the --destination-port 옵션 of the TCP 확장 for details.
unclean
This module takes no 옵션s, but attempts to match packets which seem malformed or unusual. This is regarded as experimental.TARGET 확장S
iptables can use extended target modules: the following are included in the standard distribution.DNAT
This target is only valid in the nat table, in the PREROUTING and OUTPUT chains, and user-defined chains which are only called from those chains. It specifies that the destination address of the packet should be modified (and all future packets in this connection will also be mangled), and rules should cease being examined. It takes one type of 옵션:- --to-destination ipaddr[-ipaddr][:port-port]
-
which can specify a single new destination IP address, an inclusive
range of IP addresses, and 옵션ally, a port range (which is only
valid if the rule also specifies
-p tcp
or
-p udp).
If no port range is specified, then the destination port will never be
modified.
-
You can add several --to-destination 옵션s. If you specify more than one destination address, either via an address range or multiple --to-destination 옵션s, a simple round-robin (one after another in cycle) load balancing takes place between these adresses.
DSCP
This target allows to alter the value of the DSCP bits within the TOS header of the IPv4 packet. As this manipulates a packet, it can only be used in the mangle table.- --set-dscp value
- Set the DSCP field to a numerical value (can be decimal or hex)
- --set-dscp-class class
- Set the DSCP field to a DiffServ class.
ECN
This target allows to selectively work around known ECN blackholes. It can only be used in the mangle table.- --ecn-tcp-remove
- Remove all ECN bits from the TCP header. Of course, it can only be used in conjunction with -p tcp.
LOG
Turn on kernel logging of matching packets. When this 옵션 is set for a rule, the Linux kernel will print some information on all matching packets (like most IP header fields) via the kernel log (where it can be read with dmesg or syslogd(8)). This is a "non-terminating target", i.e. rule traversal continues at the next rule. So if you want to LOG the packets you refuse, use two separate rules with the same matching criteria, first using target LOG then DROP (or REJECT).- --log-level level
- Level of logging (numeric or see syslog.conf(5)).
- --log-prefix prefix
- Prefix log messages with the specified prefix; up to 29 letters long, and useful for distinguishing messages in the logs.
- --log-tcp-sequence
- Log TCP sequence numbers. This is a security risk if the log is readable by users.
- --log-tcp-옵션s
- Log 옵션s from the TCP packet header.
- --log-ip-옵션s
- Log 옵션s from the IP packet header.
MARK
This is used to set the netfilter mark value associated with the packet. It is only valid in the mangle table. It can for 예 be used in conjunction with iproute2.- --set-mark mark
-
MASQUERADE
This target is only valid in the nat table, in the POSTROUTING chain. It should only be used with dynamically assigned IP (dialup) connections: if you have a static IP address, you should use the SNAT target. Masquerading is equivalent to specifying a mapping to the IP address of the interface the packet is going out, but also has the effect that connections are forgotten when the interface goes down. This is the correct behavior when the next dialup is unlikely to have the same interface address (and hence any established connections are lost anyway). It takes one 옵션:- --to-ports port[-port]
- This specifies a range of source ports to use, overriding the default SNAT source port-selection heuristics (see above). This is only valid if the rule also specifies -p tcp or -p udp.
MIRROR
This is an experimental demonstration target which inverts the source and destination fields in the IP header and retransmits the packet. It is only valid in the INPUT, FORWARD and PREROUTING chains, and user-defined chains which are only called from those chains. 주의 that the outgoing packets are NOT seen by any packet filtering chains, connection tracking or NAT, to avoid loops and other problems.REDIRECT
This target is only valid in the nat table, in the PREROUTING and OUTPUT chains, and user-defined chains which are only called from those chains. It alters the destination IP address to send the packet to the machine itself (locally-generated packets are mapped to the 127.0.0.1 address). It takes one 옵션:- --to-ports port[-port]
- This specifies a destination port or range of ports to use: without this, the destination port is never altered. This is only valid if the rule also specifies -p tcp or -p udp.
REJECT
This is used to send back an 에러 packet in response to the matched packet: otherwise it is equivalent to DROP so it is a terminating TARGET, ending rule traversal. This target is only valid in the INPUT, FORWARD and OUTPUT chains, and user-defined chains which are only called from those chains. The following 옵션 controls the nature of the 에러 packet returned:- --reject-with type
-
The type given can be
icmp-net-unreachable icmp-host-unreachable icmp-port-unreachable icmp-proto-unreachable icmp-net-prohibited icmp-host-prohibited or icmp-admin-prohibited (*)
which return the appropriate ICMP 에러 message (port-unreachable is the default). The 옵션 tcp-reset can be used on rules which only match the TCP protocol: this causes a TCP RST packet to be sent back. This is mainly useful for blocking ident (113/tcp) probes which frequently occur when sending mail to broken mail hosts (which won't accept your mail otherwise). - (*) Using icmp-admin-prohibited with kernels that do not support it will result in a plain DROP instead of REJECT
-
SNAT
This target is only valid in the nat table, in the POSTROUTING chain. It specifies that the source address of the packet should be modified (and all future packets in this connection will also be mangled), and rules should cease being examined. It takes one type of 옵션:- --to-source ipaddr[-ipaddr][:port-port]
-
which can specify a single new source IP address, an inclusive range
of IP addresses, and 옵션ally, a port range (which is only valid if
the rule also specifies
-p tcp
or
-p udp).
If no port range is specified, then source ports below 512 will be
mapped to other ports below 512: those between 512 and 1023 inclusive
will be mapped to ports below 1024, and other ports will be mapped to
1024 or above. Where possible, no port alteration will occur.
-
You can add several --to-source 옵션s. If you specify more than one source address, either via an address range or multiple --to-source 옵션s, a simple round-robin (one after another in cycle) takes place between these adresses.
TCPMSS
This target allows to alter the MSS value of TCP SYN packets, to control the maximum size for that connection (usually limiting it to your outgoing interface's MTU minus 40). Of course, it can only be used in conjunction with -p tcp.This target is used to overcome criminally braindead ISPs or servers which block ICMP Fragmentation Needed packets. The symptoms of this problem are that everything works fine from your Linux firewall/router, but machines behind it can never exchange large packets:
-
- 1)
- Web browsers connect, then hang with no data received.
- 2)
- Small mail works fine, but large emails hang.
- 3)
- ssh works fine, but scp hangs after initial handshaking.
iptables -A FORWARD -p tcp --tcp-플래그 SYN,RST SYN \ -j TCPMSS --clamp-mss-to-pmtu
- --set-mss value
- Explicitly set MSS 옵션 to specified value.
- --clamp-mss-to-pmtu
- Automatically clamp MSS value to (path_MTU - 40).
- These 옵션s are mutually exclusive.
-
TOS
This is used to set the 8-bit Type of Service field in the IP header. It is only valid in the mangle table.- --set-tos tos
-
You can use a numeric TOS values, or use
iptables -j TOS -h
to see the list of valid TOS 이름s.
ULOG
This target provides userspace logging of matching packets. When this target is set for a rule, the Linux kernel will multicast this packet through a netlink socket. One or more userspace processes may then subscribe to various multicast groups and receive the packets. Like LOG, this is a "non-terminating target", i.e. rule traversal continues at the next rule.- --ulog-nlgroup nlgroup
- This specifies the netlink group (1-32) to which the packet is sent. Default value is 1.
- --ulog-prefix prefix
- Prefix log messages with the specified prefix; up to 32 characters long, and useful for distinguishing messages in the logs.
- --ulog-cprange size
- Number of bytes to be copied to userspace. A value of 0 always copies the entire packet, regardless of its size. Default is 0.
- --ulog-qthreshold size
-
Number of packet to queue inside kernel. Setting this value to, e.g. 10
accumulates ten packets inside the kernel and transmits them as one
netlink multipart message to userspace. Default is 1 (for backwards
compatibility).
진단
Various 에러 messages are printed to standard 에러. The exit code is 0 for correct functioning. 에러s which appear to be caused by invalid or abused 명령 line parameters cause an exit code of 2, and other 에러s cause an exit code of 1.버그
버그? What's this? 😉 Well... the counters are not reliable on sparc64.호환 WITH IPCHAINS
This iptables is very similar to ipchains by Rusty Russell. The main difference is that the chains INPUT and OUTPUT are only traversed for packets coming into the local host and originating from the local host respectively. Hence every packet only passes through one of the three chains (except loopback traffic, which involves both INPUT and OUTPUT chains); previously a forwarded packet would pass through all three.The other main difference is that -i refers to the input interface; -o refers to the output interface, and both are available for packets entering the FORWARD chain.
iptables is a pure packet filter when using the default `filter' table, with 옵션al 확장 modules. This should simplify much of the previous confusion over the combination of IP masquerading and packet filtering seen previously. So the following 옵션s are handled differently:
-j MASQ -M -S -M -LThere are several other changes in iptables.
관련 항목
iptables-save(8), iptables-restore(8), ip6tables(8), ip6tables-save(8), ip6tables-restore(8). The packet-filtering-HOWTO details iptables 사용법 for packet filtering, the NAT-HOWTO details NAT, the netfilter-확장s-HOWTO details the 확장s that are not in the standard distribution, and the netfilter-hacking-HOWTO details the netfilter internals.See http://www.netfilter.org/.
저자S
Rusty Russell wrote iptables, in early consultation with Michael Neuling.Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet selection framework in iptables, then wrote the mangle table, the owner match, the mark stuff, and ran around doing cool stuff everywhere.
James Morris wrote the TOS target, and tos match.
Jozsef Kadlecsik wrote the REJECT target.
Harald Welte wrote the ULOG target, TTL, DSCP, ECN matches and targets.
The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Jozsef Kadlecsik, James Morris, Harald Welte and Rusty Russell.
Man page written by Herve Eychenne <rv@wallfire.org>. ---- CategoryManPage ---- CategoryManPage