테스트 사이트 - 개발 중인 베타 버전입니다

iptables 관련

· 13년 전 · 384
Describe iptables 관련 자료 here

  • 체인 생성 (-N).
  • 체인 제거 (-X).
  • 체인 정책 변경 (-P)
  • 체인 규칙 나열 (-L)
  • 체인 규칙들 삭제 (-F)
  • 체인 규칙 패킷과 바이트 카운드 0 (-Z)

체인 내부 규칙 조작 


  • 규칙 추가 (-A)
  • 규칙 삽입 (-I)
  • 규칙 교환 (-R)
  • 규칙 제거 (-D) 

세부 내용 


  • 127.0.0.1 은 'loopback' 인터페이스
  • 테스트에 유용
byoungguk@linuxtip:~$ ping -c 1 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.040 ms

--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms

[root@localhost ~]# iptables -L -n
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  

  • ping 막기
[root@localhost ~]# iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP
[root@localhost ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       icmp --  127.0.0.1            0.0.0.0/0          

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@localhost ~]# ping -c 1 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.

--- 127.0.0.1 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms


  • 규칙 제거
[root@localhost ~]# iptables -D INPUT 1
[root@localhost ~]# iptables -L -n
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  
[root@localhost ~]# iptables -D INPUT -s 127.0.0.1 -p icmp -j DROP
[root@localhost ~]# iptables -L -n
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         

  • 옵션
'-s', '--source', '--src'
'-d', '--destination', '--dst'
'-s ! localhost' => localhost 로 부터 오는 패킷 아닌 경우
'-p ! TCP'
'-i'('--in-interface')와 '-o'('--out-interface')

  • 체인 생성
[root@localhost ~]# iptables -N byoungguk
[root@localhost ~]# iptables -L -n
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         

Chain byoungguk (0 references)
target     prot opt source               destination

  • 체인 삭제
[root@localhost ~]# iptables -L -n
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 

  • 체인 세부 내용 비우기
[root@localhost ~]# iptables -F FORWARD

  • 모든 체인 내용 비우기
[root@localhost ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       icmp --  127.0.0.1            0.0.0.0/0           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DROP       icmp --  127.0.0.1            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       icmp --  127.0.0.1            0.0.0.0/0           
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -L -n
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    

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
8265
20403
20402
20401
20400
8259
20399
20398
8255
8249
8246
8242
20396
8240
20395
20394
31033
28385
20393
28380
20392
28377
20391
20390
20389
20388
20387
20386
20385
20384
20383
20382
8238
20380
20379
28376
28372
20378
20377
8235
20375
20374
20373
20372
20371
20370
28370
20369
28366
20368
20367
20366
20365
20364
20363
20362
20361
20360
20359
8231
20358
20357
20356
20355
20354
20353
20352
20351
20350
20349
20348
20347
20346
20345
20344
20343
20342
20341
20340
20339
20338
20337
20336
20335
20334
20333
20332
20331
20330
20329
20328
20327
20326
20325
20324
20323
20322
20321
20320
20319