iptables string 을 이용한 차단...

vlzkcbcb의 이미지

PC(90.90.90.2)===Router====WAN 입니다.

라우터장비에서 NAT 도 해주면서 아래룰을 적용하여 DNS 쿼리가 막히는지 테스트해보았습니다.

iptables -I FORWARD -m string --string "nateon.nate.com" --algo kmp -j DROP

PC에서는 DNS 캐쉬를 삭제한 상태입니다. tcpdump 결과는 아래와 같았습니다.

00:00:09.389676 90.90.90.2.55907 > 168.126.63.1.53:  55400+ A? nateon.nate.com. (33)
00:00:09.397926 168.126.63.1.53 > 90.90.90.2.55907:  55400 1/3/3 A 211.234.239.58 (151)

네...아주 잘받아오네요 ㅡㅡ;; 받아오면 안되는데 말이죠...

그런데 iptables -L -v 했을때 DROP 부분에 패킷이 싸여있습니다.

어찌된일일까요? ㅠㅠ

그런데 아래룰로 할때는 쿼리를 받아오질 못하더군요.

iptables -I FORWARD -m string --string "nate" --algo kmp -j DROP

도움부탁드립니다.

bushi의 이미지

http://www.tcpipguide.com/free/t_DNSNameNotationandMessageCompressionTechnique.htm

[bushi@rose cts_math]$ sudo tcpdump -n -XX  -i eth0 udp port 53
...
	0x0000:  0025 6495 f452 0013 c389 d044 0800 4500  .%d..R.....D..E.
	0x0010:  004d 2579 0000 7911 df73 930b 3980 80e0  .M%y..y..s..9...
	0x0020:  ef47 0035 b498 0039 1ab0 da55 8180 0001  .G.5...9...U....
	0x0030:  0001 0000 0000 066e 6174 656f 6e04 6e61  .......nateon.na
	0x0040:  7465 0363 6f6d 0000 0100 01c0 0c00 0100  te.com..........
	0x0050:  0100 0001 cc00 04d3 eaef 3a              ..........:
...

0x06 nateon 0x04 nate 0x03 com 0x00
[bushi@rose cts_math]$ iptables -m string  --help
...
string match options:
--from                       Offset to start searching from
--to                         Offset to stop searching
--algo                       Algorithm
--icase                      Ignore case (default: 0)
[!] --string string          Match a string in a packet
[!] --hex-string string      Match a hex string in a packet

OTL

bushi의 이미지

agkrwyasym의 이미지

참고로, l7-filter는 세션 첫 10개 패캣 또는 2kB(최대64kB)만 검색합니다. 그 이후는 매칭이 안되죠.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.