brunch

You can make anything
by writing

C.S.Lewis

by Younggi Seo Jul 25. 2021

iptables 우분투 리눅스 매뉴얼

by James Morris




제임스 모리슨이라고 그의 브릿팝을 따라 부른 적이 있다. 그의 곡 'You give me something'을 모창 하며 클래식 기타도 배우려고 기타도 하나 장만한 때가 있었는데, 호주 위킹 홀리데이를 보내기 위해 멜버른을 관광할 때 뮤직비디오에서의 그의 모습과 같이 버스킹을 하는 버스커를 많이 보았다.



대학생 시절, 딱히 뭐 하나 남는 기억은 없는데, 서점가에서 한창 잘 팔리던 '시크릿'이라는 책에서의 '끌어당김의 법칙'이라는 게 기억난다. 그리고 그 끌어당김 법칙의 증명은 당시 오프라 윈프리 쇼에서 그 책의 내용대로 부의 법칙을 실현한 보통 미국인들이 초대되어 인터뷰하던 방송을 본 것도 기억난다.



끌어당김의 법칙



 그대로 본인이 좋아하던 싫어하던(싫은  기억의 잔상에   남으므로) 어떤 대상을 머릿속에 그리면  대상이  현실 속에서 나타난다는 법칙이다. '시크릿'이라는 책이 한때 선풍적으로 팔리던 때에 많은 사람들이  법칙을 곧이곧대로 받아들이며 부자가 되기 위해 피상적으로 자신의 장밋빛 미래를 열망한 적이 있었으리라고 짐작된다. 하지만 그런 류의 책은 '그렇다고 생각하면 진짜 그렇게 된다'라는 삭티 거웨인이 지은 책부터 계속 돌고 내용이다(한국판 '꿈꾸는 다락방'처럼 말이다). 아마도 고졸 출신의 자수성가해서 페라리와 람보르기니를 끌고 다니는 김태광 (필명 김도사) 부자가 되기 위해서 매일 자신의 버킷리스트를 필사하게 만든 , 가브리엘의 '                   '부터 "머릿속에 각인시키면 이루어지리라." 태고 때부터 돌고도는 메시지일 것이다.



서두가 돌고 돌았다. 대학생 때 학교의 국제어학원에서 원어민 강사의 영어회화 수업을 들은 적이 있다. 그때 함께 수강했던 관광학과의 한 여학생과 좋아하는 가수로 서로 회화 연습을 했다. 이후 그녀가 토익 고득점자들에게 주어진 미국 해외 연수를 받고 돌아와서, 내가 좋아하는 가수의 CD를 구매했다며 보여주려 한 적이 있었다. 하지만 제임스 모리슨이 아니라 미국의 오래된 가수 '짐 모리슨'이었기에 그 CD를 거절(?)한 적이 있었는데... 내 머릿속에 아무리 '제임스 모리슨'의 'You give me something'의 노래 가사가 맴돌고 있더라도 끌어당김의 법칙은 섬세하지 않으면, 현실에서 구현은 어려우리라.



근래 산업통상자원부() 감사 기간이었는데, 운영하고 있는 보안시스템의 내부 접근 허용 IP 특정 포트(ssh, https)로만 설정되어 있지 않아서 고객사로부터 지적받았다. 몇몇 시스템은 어플라이언스 장비임에도 불구하고 자체 애플리케이션(GUI)에서 허용 IP 설정하지 않았고, 메모리에 고정시킨(embeded) IOS 커스터마이징한 리눅스(CentOS 7.4) 사용했다. 그런데 해당 OS 내부 서비스인 firewalld라는 방화벽 IP filter에는 허용 IP  PORT 설정되어 있지 않았으며, iptables라는 구버전의 내부 방화벽 서비스 데몬도 프로세싱 중이지도 않은  정책만이 설정되어 있었다. 그래서 해당 OS 호환 가능한 iptables service 버전을 외부 인터넷망으로부터 다운로드해서 기본적인 접근 허용 IP 재설정해야 했다.



iptables는 정보보안기사를 공부하면서 특정 공격을 어떻게 차단하는지에 대한 구문만 익히고 있었던지라 기본 세팅이 어떻게 이루어지는지는 검색해봐야 했고, 아래 사이트가 매뉴얼로써는 제격이었다. 그리고 우분투 리눅스에서 이 소프트웨어 방화벽 서비스 매뉴얼(man iptables)을 훑어봤다. 매뉴얼의 맨 아래에 이것을 쓴 사람 중 한 명이 'James Morris'로 되어있어서 내 머릿속에 각인된 가수의 이름이 드디어 끌어당겨졌나 싶었지만 정확하게는 James Morrison이라서 아직도 나에게 부의 시크릿은 미지수로 남아있는 거 같다.


 



일단, iptables는 이스라엘의 checkpoint라는 보안업체의 넷필터 프로젝트에서 최초로 개발한 기능으로 광범위한 프로토콜 상태 추적, 패킷 애플리케이션 계층 검사 속도 제한, 필터링 정책을 명시하기 위한 메커니즘을 제공하는 S/W 방화벽이다. 오픈소스로 linux 시스템에서 사용되고, 상태 추적 기능과 로깅 기능, 포트 포워딩 및 향상된 매칭 기능을 제공해줘 많은 방화벽 장비에서도 사용되고 있다.



그래서 오늘날 대부분의 방화벽에서 기본으로 제공하는 기능(iptables에서 현재 linux kernel 3.13 버전 이후로는 nftables로 업그레이드됨)이며, 상태 추적(Stateful Inspection) 테이블을 생성하여 연결 정보를 가지고 있는 모든 송수신 패킷을 일정 시간 동안 유지함으로써 보다 빠르고 높은 보안성을 제공한다. 그리고 연결된 상태의 패킷인 것처럼 위조한 패킷의 접근을 차단할 수 있으므로 보안상의 장점을 가질 뿐만 아니라 연결된 상태의 패킷에 대해서는 더 이상의 검사를 수행하지 않으므로 성능상의 장점도 가진다.



기본적으로 탑다운(Top-down)의 블랙리스트 차단 정책으로 일반적인 H/W 방화벽과 동일한 내림차순의 우선순위를 가진다. 다만 위에서부터 차례로 정책을 적용하고 디폴트로 -P(olicy)라는 옵션으로 세팅한 정책에서 지정한 타깃(ACCEPT / DROP / REJECT: icmp 응답 메시지를 상대에게 보냄)이 무조건 이루어진다. linux kenel 3.13 이후에도 iptables를 계속 사용하려는 사용자는 아래와 같은 특성을 염두에 두어야 한다.


1) iptables는 kernel 2.4 이전 버전에서 사용되던 ipchains를 대신하는 firewall 도구임.

2) iptables는 kernel에서 netfilter 패킷(packet) 필터링(filtering) 기능을 사용자 공간에서 제어하는 수준으로 사용하고, protocol 상태 추적, packet 애플리케이션(application) 계층(layer) 검사, 속도 제한, filtering 정책(policy) 등의 기능을 제공함.

3) ubuntu 18.04 이후 버전은 기본적으로 iptables와 함께 UFW(Uncomplicated Firewall, ufw)를 제공함.

*4) iptables를 설정하기 전에 ufw를 비활성화하거나 제거하는 것을 추천함.

5) iptables 설정에는 루트 권한을 요구하기 때문에, 이 포스트에서는 루트 사용자가 설정한다는 가정하에 설명함.


아래가 iptables의 아무것도 설정하지 않은 기본적인 룰셋이다.

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT) target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT) target prot opt source destination


아래와 같이 iptables -L(ist) 명령을 통해 현재 설정된 정책(rule set)을 확인할 수 있다.

root@DANIEL-4938DB:/etc/network# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination


현재는 정책이 미설정된 벌크 상태이기 때문에 iptables -A(ppend) 혹은 -I(nsert) 옵션을 통해 맨 아래에 추가하거나 특정행을 지정해서 추가할 수 있다. 특정행은 먼저 기존 정책의 행번호를 확인한 뒤에 아래와 같이 그 행번호의 중간행이나 다음행을 지정해서 추가할 수 있다.

root@DANIEL-4938DB:/etc/network# iptables -L --line-numbers
Chain INPUT (policy DROP)
num  target     prot opt source               destination
1    ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
2    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
3    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)



root@DANIEL-4938DB:/etc/network# iptables -I INPUT 2 -p tcp -m conntrack --ctstate NEW -m limit --limit 60/s --limit-burst 20 -j ACCEPT


위 커맨드 라인에서 맨 아래에 있는 새로 삽입하는 iptables의 룰은 TCP 커넥션 통신 간에 SYN 패킷을 다량으로 받아서 자원의 서비스 가용성을 떨어뜨리는 공격(SYN flooding)을 막기 위한 정책이다.


iptables 룰 세팅은 기본적으로 필터 테이블(-t가 없을 때 적용)로 순차적으로 적용하며, 명령(command) / 체인(chain) / 옵션(parameter) / 타깃(target)으로 구성된다. 다시 새로 삽입한 iptables 명령 구문의 의미를 살펴보겠다.


# iptables -I INPUT 2 -p tcp -m conntrack --ctstate NEW -m limit --limit 60/s --limit-burst 20 -j ACCEPT


-I(nsert) 삽입 명령을 통해 INPUT 체인의 2번째 행에 ACCEPT 타깃을 추가하는데, 포트는 tcp로 ingress(외부에서 내부로 향하는)하는 패킷(INPUT 체인이기 때문에, 만약 OUTPUT 체인이면 egrees)을 필터링하여 conntrack(connection not ACK)이라는 새로운 매치(match)명으로 룰을 세팅한다. 초당 60회를 넘지 않은 tcp 패킷을 허용하는 것을 목표로 두는 것을 -m(매칭 옵션)을 통해 설정했다. 일종의 DoS(Denial of Service, 서비스 거부) 공격을 막기 위한 정책 설정이다. 아래 사이트에서 해당 룰 이외 분산 서비스 거부 공격(DDoS, Distributed Denial of Service)을 막기 위한 ipatables(Ubuntu 및 CentOS 공용) 정책 예시를 살펴볼 수 있다. 그리고 맨 아래는 제임스 모리스가 부분 작성한 iptables의 매뉴얼(Ubuntu 20.04.2 LTS 기준 iptables 1.8.4)을 살펴볼 수 있다.



중요한 것은 위의 정책을 모두 적용하고도 아래와 같은 명령을 타이핑하지 않으면 정책 설정이 저장되지 않거나 시스템 재시작 후 복구가 되지 않아, 기본 세팅(아무 룰도 없는 깡통)으로 되돌아갈 수 있다.



# iptables -S -v


S 옵션은 reusable output, 즉 재사용을 위한 출력으로 -L(ist)처럼 참조용으로 보여주기가 아니라, iptables-save 방식으로 생성되어 iptables-apply 및 iptables-restore에 다시 사용할 수 있다. 그러므로 위의 명령어 한 방으로 아래와 같은 centOS에서의 iptables 룰 세팅 저장 및 서비스 재시작(iptables-service 설치했을 시)을 할 필요가 없어진다.

1) iptables 룰 세팅 저장 / 덮어쓰기 / 기존의 정책을 유지히면서 새로운 룰셋 적용
     
   root@DANIEL-4938DB:/etc/sysconfig# iptables-save > /etc/sysconfig/iptables

# Overwrite the current rules
   root@DANIEL-4938DB:/etc/sysconfig# iptables-restore < /etc/sysconfig/iptables

# Add the new rules keeping the current ones  
   root@DANIEL-4938DB:/etc/sysconfig# iptables-restore -n < /etc/sysconfig/iptables

2) iptables-service 유니트(프로세스) 기동 및 적용/저장

  yum install iptables-services
  systemctl start iptables
  systemctl enable iptables
  service iptables save




* 4) iptables는 리눅스 커널 단에서 운용되는 서비스 유니트다. 만약 사이트의 보안시스템(어플라이언스)의 OS가 펌웨어 버전(IOS)으로 메모리에 심어져 있다면, 기본적으로 깔려있는 firewalld 서비스를 삭제하기보다는 firewall 데몬의 서비스를 중단 및 마스킹(masking)하고 iptables-service 패키지를 추가 설치해서 사용하기를 권장함.




IPTABLES(8)                                                                    iptables 1.8.4


NAME

       iptables/ip6 tables — administration tool for IPv4/IPv6 packet filtering and NAT


SYNOPSIS

       iptables [-t table] {-A|-C|-D} chain rule-specification


       ip6 tables [-t table] {-A|-C|-D} chain rule-specification


       iptables [-t table] -I chain [rulenum] rule-specification


       iptables [-t table] -R chain rulenum rule-specification


       iptables [-t table] -D chain rulenum


       iptables [-t table] -S [chain [rulenum]]


       iptables [-t table] {-F|-L|-Z} [chain [rulenum]] [options...]


       iptables [-t table] -N chain


       iptables [-t table] -X [chain]


       iptables [-t table] -P chain target


       iptables [-t table] -E old-chain-name new-chain-name


       rule-specification = [matches...] [target]


       match = -m matchname [per-match-options]


       target = -j targetname [per-target-options]


DESCRIPTION

       Iptables  and  ip6 tables are used to set up, maintain, and inspect the tables of IPv4 and IPv6 packet filter rules in the Linux kernel.  Several different tables may

       be defined.  Each table contains a number of built-in chains and may also contain user-defined chains.


       Each chain is a list of rules which can match a set of packets.  Each rule specifies what to do with a packet that matches.  This is called a `target', which may  be

       a jump to a user-defined chain in the same table.


TARGETS

       A  firewall rule specifies criteria for a packet and a target.  If the packet does not match, the next rule in the chain is examined; if it does match, then the next

       rule is specified by the value of the target, which can be the name of a user-defined chain, one of the targets described in iptables-extensions(8), or  one  of  the

       special values ACCEPT, DROP or RETURN.


       ACCEPT means to let the packet through.  DROP means to drop the packet on the floor.  RETURN means stop traversing this chain and resume at the next rule in the pre‐

       vious (calling) chain.  If the end of a built-in chain is reached or a rule in a built-in chain with target RETURN is matched, the target specified by the chain pol‐

       icy determines the fate of the packet.


TABLES

       There are currently five independent tables (which tables are present at any time depends on the kernel configuration options and which modules are present).


       -t, --table table

              This  option  specifies  the packet matching table which the command should operate on.  If the kernel is configured with automatic module loading, an attempt

              will be made to load the appropriate module for that table if it is not already there.

The tables are as follows:


              filter:

                  This is the default table (if no -t option is passed). It contains the built-in chains INPUT (for packets destined to local sockets), FORWARD (for packets

                  being routed through the box), and OUTPUT (for locally-generated packets).


              nat:

                  This  table  is  consulted when a packet that creates a new connection is encountered.  It consists of four built-ins: PREROUTING (for altering packets as

                  soon as they come in), INPUT (for altering packets destined for local sockets), OUTPUT  (for  altering  locally-generated  packets  before  routing),  and

                  POSTROUTING (for altering packets as they are about to go out).  IPv6 NAT support is available since kernel 3.7.


              mangle:

                  This  table  is  used for specialized packet alteration.  Until kernel 2.4.17 it had two built-in chains: PREROUTING (for altering incoming packets before

                  routing) and OUTPUT (for altering locally-generated packets before routing).  Since kernel 2.4.18, three other built-in chains are also  supported:  INPUT

                  (for  packets  coming into the box itself), FORWARD (for altering packets being routed through the box), and POSTROUTING (for altering packets as they are

                  about to go out).


              raw:

                  This table is used mainly for configuring exemptions from connection tracking in combination with the NOTRACK target.  It registers at the netfilter hooks

                  with  higher  priority and is thus called before ip_conntrack, or any other IP tables.  It provides the following built-in chains: PREROUTING (for packets

                  arriving via any network interface) OUTPUT (for packets generated by local processes)


              security:

                  This table is used for Mandatory Access Control (MAC) networking rules, such as those enabled by the SECMARK and CONNSECMARK  targets.   Mandatory  Access

                  Control  is implemented by Linux Security Modules such as SELinux.  The security table is called after the filter table, allowing any Discretionary Access

                  Control (DAC) rules in the filter table to take effect before MAC rules.  This table provides the following built-in chains:  INPUT  (for  packets  coming

                  into the box itself), OUTPUT (for altering locally-generated packets before routing), and FORWARD (for altering packets being routed through the box).


OPTIONS

       The options that are recognized by iptables and ip6 tables can be divided into several different groups.


   COMMANDS

       These  options  specify  the desired action to perform. Only one of them can be specified on the command line unless otherwise stated below. For long versions of the

       command and option names, you need to use only enough letters to ensure that iptables can differentiate it from all other options.


       -A, --append chain rule-specification

              Append one or more rules to the end of the selected chain.  When the source and/or destination names resolve to more than one address, a rule  will  be  added

              for each possible address combination.


       -C, --check chain rule-specification

              Check  whether  a  rule matching the specification does exist in the selected chain. This command uses the same logic as -D to find a matching entry, but does

              not alter the existing iptables configuration and uses its exit code to indicate success or failure.


       -D, --delete chain rule-specification

       -D, --delete chain rulenum

              Delete one or more rules from the selected chain.  There are two versions of this command: the rule can be specified as a number in the chain (starting  at  1

              for the first rule) or a rule to match.


       -I, --insert chain [rulenum] rule-specification

              Insert  one  or  more  rules  in  the selected chain as the given rule number.  So, if the rule number is 1, the rule or rules are inserted at the head of the

              chain.  This is also the default if no rule number is specified.


       -R, --replace chain rulenum rule-specification

              Replace a rule in the selected chain.  If the source and/or destination names resolve to multiple addresses, the command will fail.  Rules are numbered start‐

              ing at 1.

-L, --list [chain]

              List  all  rules  in the selected chain.  If no chain is selected, all chains are listed. Like every other iptables command, it applies to the specified table

              (filter is the default), so NAT rules get listed by

               iptables -t nat -n -L

              Please note that it is often used with the -n option, in order to avoid long reverse DNS lookups.  It is legal to specify the -Z (zero)  option  as  well,  in

              which case the chain(s) will be atomically listed and zeroed.  The exact output is affected by the other arguments given. The exact rules are suppressed until

              you use

               iptables -L -v

              or iptables-save(8).


       -S, --list-rules [chain]

              Print all rules in the selected chain.  If no chain is selected, all chains are printed like iptables-save. Like every other iptables command, it  applies  to

              the specified table (filter is the default).


       -F, --flush [chain]

              Flush the selected chain (all the chains in the table if none is given).  This is equivalent to deleting all the rules one by one.


       -Z, --zero [chain [rulenum]]

              Zero  the packet and byte counters in all chains, or only the given chain, or only the given rule in a chain. It is legal to specify the -L, --list (list) op‐

              tion as well, to see the counters immediately before they are cleared. (See above.)


       -N, --new-chain chain

              Create a new user-defined chain by the given name.  There must be no target of that name already.


       -X, --delete-chain [chain]

              Delete the optional user-defined chain specified.  There must be no references to the chain.  If there are, you must delete or replace the referring rules be‐

              fore  the  chain  can  be deleted.  The chain must be empty, i.e. not contain any rules.  If no argument is given, it will attempt to delete every non-builtin

              chain in the table.


       -P, --policy chain target

              Set the policy for the built-in (non-user-defined) chain to the given target.  The policy target must be either ACCEPT or DROP.


       -E, --rename-chain old-chain new-chain

              Rename the user specified chain to the user supplied name.  This is cosmetic, and has no effect on the structure of the table.


       -h     Help.  Give a (currently very brief) description of the command syntax.


   PARAMETERS

       The following parameters make up a rule specification (as used in the add, delete, insert, replace and append commands).


       -4, --ipv4

              This option has no effect in iptables and iptables-restore.  If a rule using the -4 option is inserted with (and only  with)  ip6 tables-restore,  it  will  be

              silently  ignored.  Any  other  uses  will throw an error. This option allows IPv4 and IPv6 rules in a single rule file for use with both iptables-restore and

              ip6tables-restore.


       -6, --ipv6

              If a rule using the -6 option is inserted with (and only with) iptables-restore, it will be silently ignored. Any other uses will throw an error. This  option

              allows  IPv4 and IPv6 rules in a single rule file for use with both iptables-restore and ip6tables-restore.  This option has no effect in ip6tables and ip6ta‐

              bles-restore.


       [!] -p, --protocol protocol

              The protocol of the rule or of the packet to check.  The specified protocol can be one of tcp, udp, udplite, icmp, icmpv6,esp, ah, sctp,  mh  or  the  special

              keyword  "all", or it can be a numeric value, representing one of these protocols or a different one.  A protocol name from /etc/protocols is also allowed.  A

              "!" argument before the protocol inverts the test.  The number zero is equivalent to all. "all" will match with all protocols and is  taken  as  default  when

              this  option  is  omitted.   Note  that, in ip6tables, IPv6 extension headers except esp are not allowed.  esp and ipv6-nonext can be used with Kernel version

              2.6.11 or later.  The number zero is equivalent to all, which means that you cannot test the protocol field for the value  0  directly.  To  match  on  a  HBH header, even if it were the last, you cannot use -p 0, but always need -m hbh.


       [!] -s, --source address[/mask][,...]

              Source  specification.  Address can be either a network name, a hostname, a network IP address (with /mask), or a plain IP address. Hostnames will be resolved

              once only, before the rule is submitted to the kernel.  Please note that specifying any name to be resolved with a remote query such as DNS is  a  really  bad

              idea.  The mask can be either an ipv4 network mask (for iptables) or a plain number, specifying the number of 1's at the left side of the network mask.  Thus,

              an iptables mask of 24 is equivalent to 255.255.255.0.  A "!" argument before the address specification inverts the sense of the address. The flag --src is an

              alias  for this option.  Multiple addresses can be specified, but this will expand to multiple rules (when adding with -A), or will cause multiple rules to be

              deleted (with -D).


       [!] -d, --destination address[/mask][,...]

              Destination specification.  See the description of the -s (source) flag for a detailed description of the syntax.  The flag --dst is an alias for this option.


       -m, --match match

              Specifies a match to use, that is, an extension module that tests for a specific property. The set of matches make up the condition under which  a  target  is

              invoked.  Matches  are evaluated first to last as specified on the command line and work in short-circuit fashion, i.e. if one extension yields false, evalua‐

              tion will stop.


       -j, --jump target

              This specifies the target of the rule; i.e., what to do if the packet matches it.  The target can be a user-defined chain (other than the  one  this  rule  is

              in), one of the special builtin targets which decide the fate of the packet immediately, or an extension (see EXTENSIONS below).  If this option is omitted in

              a rule (and -g is not used), then matching the rule will have no effect on the packet's fate, but the counters on the rule will be incremented.


       -g, --goto chain

              This specifies that the processing should continue in a user specified chain. Unlike the --jump option return will not continue processing in this  chain  but

              instead in the chain that called us via --jump.


       [!] -i, --in-interface name

              Name  of an interface via which a packet was received (only for packets entering the INPUT, FORWARD and PREROUTING chains).  When the "!" argument is used be‐

              fore the interface name, the sense is inverted.  If the interface name ends in a "+", then any interface which begins with this name will match.  If this  op‐

              tion is omitted, any interface name will match.


       [!] -o, --out-interface name

              Name  of an interface via which a packet is going to be sent (for packets entering the FORWARD, OUTPUT and POSTROUTING chains).  When the "!" argument is used

              before the interface name, the sense is inverted.  If the interface name ends in a "+", then any interface which begins with this name will  match.   If  this

              option is omitted, any interface name will match.


       [!] -f, --fragment

              This  means  that  the  rule  only refers to second and further IPv4 fragments of fragmented packets.  Since there is no way to tell the source or destination

              ports of such a packet (or ICMP type), such a packet will not match any rules which specify them.  When the "!" argument precedes the "-f" flag, the rule will

              only match head fragments, or unfragmented packets. This option is IPv4 specific, it is not available in ip6tables.


       -c, --set-counters packets bytes

              This enables the administrator to initialize the packet and byte counters of a rule (during INSERT, APPEND, REPLACE operations).


   OTHER OPTIONS

       The following additional options can be specified:


       -v, --verbose

              Verbose  output.   This option makes the list command show the interface name, the rule options (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 append‐

              ing,  insertion, deletion and replacement, this causes detailed information on the rule or rules to be printed. -v may be specified multiple times to possibly

              emit more detailed debug statements.


       -w, --wait [seconds]

              Wait for the xtables lock.  To prevent multiple instances of the program from running concurrently, an attempt will be made to obtain  an  exclusive  lock  at

              launch.   By default, the program will exit if the lock cannot be obtained.  This option will make the program wait (indefinitely or for optional seconds) un‐

til the exclusive lock can be obtained.


       -W, --wait-interval microseconds

              Interval to wait per each iteration.  When running latency sensitive applications, waiting for the xtables lock for extended durations may not be  acceptable.

              This option will make each iteration take the amount of time specified. The default interval is 1 second. This option only works with -w.


       -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 names, network

              names, 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 option is only relevant for the -L command.


       --line-numbers

              When listing rules, add line numbers to the beginning of each rule, corresponding to that rule's position in the chain.


       --modprobe=command

              When adding or inserting rules into a chain, use command to load any necessary modules (targets, match extensions, etc).


MATCH AND TARGET EXTENSIONS

       iptables can use extended packet matching and target modules.  A list of these is available in the iptables-extensions(8) manpage.


DIAGNOSTICS

       Various  error  messages  are  printed to standard error.  The exit code is 0 for correct functioning.  Errors which appear to be caused by invalid or abused command

       line parameters cause an exit code of 2, and other errors cause an exit code of 1.


BUGS

       Bugs?  What's this? ;-) Well, you might want to have a look at http://bugzilla.netfilter.org/


COMPATIBILITY 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.


       The various forms of NAT have been separated out; iptables is a pure packet filter when using the default `filter' table,  with  optional  extension  modules.   This

       should  simplify  much  of the previous confusion over the combination of IP masquerading and packet filtering seen previously.  So the following options are handled

       differently:

        -j MASQ

        -M -S

        -M -L

       There are several other changes in iptables.


SEE ALSO

       iptables-apply(8), iptables-save(8), iptables-restore(8), iptables-extensions(8),


       The packet-filtering-HOWTO details iptables usage for packet filtering, the NAT-HOWTO details NAT, the netfilter-extensions-HOWTO details the extensions that are not

       in the standard distribution, and the netfilter-hacking-HOWTO details the netfilter internals.

       See http://www.netfilter.org/.


AUTHORS

       Rusty Russell originally 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 and NFQUEUE target, the new libiptc, as well as the TTL, DSCP, ECN matches and targets.


       The Netfilter Core Team is: Jozsef Kadlecsik, Pablo Neira Ayuso, Eric Leblond, Florian Westphal and  Arturo Borrero Gonzalez.  Emeritus Core Team members  are:  Marc

       Boucher, Martin Josefsson, Yasuyuki Kozakai, James Morris, Harald Welte and Rusty Russell.


       Man page originally written by Herve Eychenne <rv@wallfire.org>.


VERSION

       This manual page applies to iptables/ip6tables 1.8.4.


iptables 1.8.4





매거진의 이전글 지능형 지속적 공격에 대한 보안장비업체에서 만든 용어
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari