{"id":1048,"date":"2019-12-05T11:13:27","date_gmt":"2019-12-05T20:13:27","guid":{"rendered":"\/blog\/?p=1048"},"modified":"2023-09-21T09:26:46","modified_gmt":"2023-09-21T00:26:46","slug":"iptables-%ea%b8%b0%eb%b3%b8-%ea%b0%9c%eb%85%90-%ec%a0%95%eb%a6%ac","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=1048","title":{"rendered":"iptables \uae30\ubcf8 \uac1c\ub150 \uc815\ub9ac"},"content":{"rendered":"\n<pre><span style=\"font-family: monospace;\">\ucd9c\ucc98: <a href=\"http:\/\/blog.naver.com\/alice_k106\/221305928714\" target=\"_blank\" rel=\"noopener\">http:\/\/blog.naver.com\/alice_k106\/221305928714<\/a><\/span><br \/><br \/><br \/><span style=\"font-family: monospace;\"><strong><span style=\"font-size: 16px;\">\u25a0 iptables \uac1c\ub150 : \ud14c\uc774\ube14\uacfc \uccb4\uc778<\/span><\/strong><\/span><br \/><br \/><span style=\"font-family: monospace;\"><span style=\"font-size: 14px;\">iptables\uc5d0\ub294 \ud14c\uc774\ube14(Table)\uacfc \uccb4\uc778(Chain) \uc774\ub77c\ub294 \ud070 \ubd84\ub958\uac00 \uc788\uc73c\uba70, \uadf8 \uc548\uc5d0 \uaddc\uce59\uc744 \uc815\uc758\ud574 \ud328\ud0b7\uc758 \ud750\ub984\uc744 \uc81c\uc5b4\ud55c\ub2e4. <\/span><span style=\"font-size: 14px;\">\ud14c\uc774\ube14\uc740 iptables\uc758 \uaddc\uce59\uc744 \uc815\uc758\ud560 \uc218 \uc788\ub294 \uac00\uc7a5 \uad11\ubc94\uc704\ud55c \ubc94\uc8fc\ub85c, \uc544\ub798\uc758 4\uac00\uc9c0 \uc885\ub958\uac00 \uc788\ub2e4. 1<\/span><\/span><br \/><br \/><span style=\"color: #843fa1; font-family: monospace;\"><span style=\"font-size: 14px;\">filter<\/span><\/span><br \/><span style=\"color: #843fa1; font-family: monospace;\"><span style=\"font-size: 14px;\">nat<\/span><\/span><br \/><span style=\"color: #843fa1; font-family: monospace;\"><span style=\"font-size: 14px;\">mangle<\/span><\/span><br \/><span style=\"color: #843fa1; font-family: monospace;\"><span style=\"font-size: 14px;\">raw<\/span><\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">\uc774 \uc911\uc5d0\uc11c filter\ub294 \ub2e8\uc5b4\uac00 \uc758\ubbf8\ud558\ub294 \ub73b \uadf8\ub300\ub85c \ud328\ud0b7\uc744 \uac78\ub7ec\ub0b4\ub294 \uc6a9\ub3c4\uc774\uba70, Inbound(\ud638\uc2a4\ud2b8\ub85c \ub4e4\uc5b4\uc624\ub294 \ud328\ud0b7) \/ Outbound(\ud638\uc2a4\ud2b8\uc5d0\uc11c \ubc16\uc73c\ub85c \ub098\uac00\ub294 \ud328\ud0b7) \ubc0f Forward(\ud638\uc2a4\ud2b8\ub97c \uac70\uccd0\uac00\ub294 \ud328\ud0b7) \ucd1d 3\uac00\uc9c0 \uc885\ub958\uc758 \ud328\ud0b7\uc744 \uc5b4\ub5bb\uac8c \ucc98\ub9ac\ud560 \uac83\uc778\uc9c0\uc5d0 \ub300\ud55c \uaddc\uce59\uc744 \uc815\uc758\ud560 \uc218 \uc788\ub2e4. \uadf8\ub807\uc9c0\ub9cc filter \ud14c\uc774\ube14\uc758 \uaddc\uce59\uc740 ufw\ub098 firewall-cmd \uc758 \uae30\ucd08\uc801\uc778 \uba85\ub839\uc5b4\ub85c\ub3c4 \uc544\uc8fc \uc27d\uac8c \uc124\uc815\ud560 \uc218 \uc788\uc744 \ubfd0\ub9cc \uc544\ub2c8\ub77c, \ub9e4\uc6b0 \uc9c1\uad00\uc801\uc778 \uae30\ub2a5\uc774\uae30 \ub54c\ubb38\uc5d0 \uad73\uc774 \ub2e4\ub8e8\uc9c0 \uc54a\uae30\ub85c \ud588\ub2e4. mangle\uacfc raw\ub294 \uc790\uc8fc \uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294 \ud14c\uc774\ube14\uc774\ubbc0\ub85c \ubcf8 \ud3ec\uc2a4\ud2b8\uc758 \uc124\uba85\uc5d0\uc11c \uc81c\uc678\ud558\uc600\ub2e4.<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">nat\ub294 \ud328\ud0b7\uc758 \uc18d\uc131\uc778 \ucd9c\ubc1c \uc8fc\uc18c(source), \ub3c4\ucc29 \uc8fc\uc18c(destination) \ub4f1\uc744 \ubcc0\uacbd\ud560 \uc218 \uc788\ub3c4\ub85d \uac01\uc885 \uaddc\uce59\uc744 \uc815\uc758\ud558\ub294 \ud14c\uc774\ube14\uc774\ub2e4. \ub77c\uc6b0\ud130(\uacf5\uc720\uae30) \ub4f1\uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 \uc8fc\uc18c \ubcc0\ud658(nat)\uc640 \ub3d9\uc77c\ud558\uc9c0\ub9cc, iptables\uc758 nat\ub294 \uc774\uc5d0 \uadf8\uce58\uc9c0 \uc54a\uace0 \ub2e4\uc591\ud55c \uc0c1\ud669\uc5d0 \ubc94\uc6a9\uc801\uc73c\ub85c \uc801\uc6a9\ud574 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4. nat \ud14c\uc774\ube14\uc758 \uc790\uc138\ud55c Use Case\ub294 \ub4a4\uc5d0\uc11c \uc124\uba85\ud560 \uac83\uc774\ub2e4.<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">iptables\uc5d0\ub294 \ud14c\uc774\ube14\uc758 \ud558\uc704 \uaddc\uce59 \uc18d\uc131\uc73c\ub85c\uc11c \uccb4\uc778(Chain) \uc774\ub77c\ub294 \uac83\uc774 \uc874\uc7ac\ud55c\ub2e4. nat\uc5d0\ub294 \uc544\ub798\uc758 \uccb4\uc778\uc744 \uc0ac\uc6a9\ud574 \uaddc\uce59\uc744 \uc815\uc758\ud560 \uc218 \uc788\ub2e4.<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\"><strong>PREROUTING (DNAT)<\/strong> : \ud328\ud0b7\uc758 \ub3c4\ucc29\uc9c0(deatination) \uc8fc\uc18c\ub97c \ubcc0\uacbd\ud55c\ub2e4. D(estination)NAT<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\"><strong>POSTROUTING (SNAT \ub610\ub294 masquerade)<\/strong> : \ud328\ud0b7\uc758 \ucd9c\ubc1c\uc9c0(source) \uc8fc\uc18c\ub97c \ubcc0\uacbd\ud55c\ub2e4. S(ource)NAT<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\"><strong>OUTPUT <\/strong>: \ud638\uc2a4\ud2b8\uc5d0\uc11c \ubc16\uc73c\ub85c \ud750\ub974\ub294 \ud328\ud0b7\uc758 \ub3c4\ucc29\uc9c0(destination) \uc8fc\uc18c\ub97c \ubcc0\uacbd\ud55c\ub2e4. (INPUT\ub3c4 \uc788\ub2e4)<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">\uac04\ub2e8\ud558\uac8c \uadf8\ub9bc\uc73c\ub85c \uc124\uba85\ud558\uba74 \uc544\ub798\uc640 \uac19\ub2e4.<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\"><img decoding=\"async\" src=\"..\/..\/..\/blog\/wp-content\/uploads\/cms_xe\/img0072.jpg\" alt=\"1.jpg\" data-file-srl=\"8061\" \/><\/span><br \/><br \/><br \/><br \/><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">\uc0ac\uc6a9\uc790\ub294 1.2.3.4:85\ub85c \uc11c\ube44\uc2a4 \uc694\uccad \ud328\ud0b7\uc744 \uc804\uc1a1\ud55c\ub2e4. \uadf8\ub7f0\ub370 \ub77c\uc6b0\ud130\uc758 \uc5ed\ud560\uc744 \ud558\ub294 \uc11c\ubc84 A(1.2.3.4) \uc5d0\ub294 1.2.3.4:85\ub85c \ub4e4\uc5b4\uc628 \ud328\ud0b7\uc758 \ubaa9\uc801\uc9c0\ub97c 5.6.7.8:80 \uc73c\ub85c \ubcc0\ud658\ud558\ub77c\ub294&nbsp; PREROUTING \uaddc\uce59\uc774 \uc788\uae30 \ub54c\ubb38\uc5d0 \ud328\ud0b7\uc758 \uc2e4\uc81c \ub3c4\ucc29\uc9c0\ub294 \uc11c\ubc84 B(5.6.7.8)\uc758 \uc6f9\uc11c\ube44\uc2a4\uc778 80 \ud3ec\ud2b8\uac00 \ub41c\ub2e4.<\/span><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\"><img decoding=\"async\" src=\"..\/..\/..\/blog\/wp-content\/uploads\/cms_xe\/img0818.jpg\" alt=\"2.jpg\" data-file-srl=\"8062\" \/><\/span><br \/><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">\uc11c\ube44\uc2a4 \uc694\uccad\uc744 \ud588\uc73c\ub2c8 \ub2f9\uc5f0\ud788 \uc774\uc5d0 \ub300\ud55c \uc751\ub2f5\uc774 \uc804\uc1a1\ub418\uc5b4\uc57c \ud55c\ub2e4. \uadf8\ub7f0\ub370 \uc11c\ubc84 B\uac00 \uc804\uc1a1\ud558\ub294 \uc751\ub2f5 \ud328\ud0b7\uc758 \ucd9c\ubc1c\uc9c0(Source)\ub294 5.6.7.8\uc774\uace0, \uc678\ubd80 \uc0ac\uc6a9\uc790\uac00 ACK\ub97c \uc815\uc0c1\uc801\uc73c\ub85c \ubc1b\uae30 \uc704\ud574\uc11c\ub294 Source\uac00 \ub2e4\uc2dc 1.2.3.4\uc73c\ub85c \ubcc0\uacbd\ub418\uc5b4\uc57c \ud55c\ub2e4. POSTROUTING\uc778 SNAT \ub8f0\uc740 \uc751\ub2f5 \ud328\ud0b7\uc758 Source\ub97c \ubcc0\uacbd\ud574 \uc0ac\uc6a9\uc790\uc5d0\uac8c \uc804\ub2ec\ud560 \uc218 \uc788\ub2e4. 3<\/span><br \/><br \/><br \/><span style=\"font-size: 14px; font-family: monospace;\">INPUT \/ OUTPUT \uccb4\uc778\ub3c4 \uc874\uc7ac\ud558\uc9c0\ub9cc, \ub098\ub294 OUTPUT \uccb4\uc778\ub9cc \uc0ac\uc6a9\ud574 \ubcf4\uc558\ub2e4. OUTPUT \uccb4\uc778\uc740 \ud638\uc2a4\ud2b8\uac00 \uc8fc\uccb4\uac00 \ub418\uc5b4 \ubc16\uc73c\ub85c \ub098\uac00\ub294 \ud328\ud0b7\uc758 \ubaa9\uc801\uc9c0\ub97c \ub2e4\ub974\uac8c \ud560 \ub54c \uc0ac\uc6a9\ub41c\ub2e4. \uc608\ub97c \ub4e4\uc5b4, curl 5.6.7.8\ub85c \uc694\uccad\uc744 \ud574\ub3c4, \uc2e4\uc81c\ub85c\ub294 9.10.11.12\ub85c \ud2b8\ub798\ud53d\uc774 \ud750\ub974\ub3c4\ub85d \uc124\uc815\ud560 \uc218 \uc788\ub2e4.<br \/><br \/><br \/>\u25a0 iptables \uc635\uc158<br \/>iptables [-t table] command [match] [target\\jump]<br \/><br \/>-A(--append) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: \uaddc\uce59 \ucd94\uac00<br \/>-N(--new-chain) &nbsp; &nbsp; &nbsp; &nbsp; : \uc0c8\ub85c\uc6b4 \uccb4\uc778 \uc0dd\uc131<br \/>-X(--delete-chain) &nbsp; &nbsp; &nbsp;: \uccb4\uc778 \uc81c\uac70<br \/>-P(--policy) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: \uccb4\uc778 \uae30\ubcf8\uc815\ucc45 \ubcc0\uacbd<br \/>-L(--list) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: \uccb4\uc778\uc758 \uaddc\uce59\uc0c1\ud0dc \ubcf4\uae30<br \/>-F(--flush) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : \uccb4\uc778\ub0b4\uc758 \ubaa8\ub4e0 \uaddc\uce59 \uc81c\uac70(\ubc29\ud654\ubcbd \ucd08\uae30\ud654)<br \/>-Z(--zero) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: \uccb4\uc778\ub0b4\uc758 \ubaa8\ub4e0 \uaddc\uce59\uc758 \ud328\ud0b7\uacfc \ubc14\uc774\ud2b8\uc758 \uce74\uc6b4\ud2b8\ub97c 0\uc73c\ub85c \ucd08\uae30\ud654<br \/>-D(--delete) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: \uaddc\uce59 \uc0ad\uc81c<br \/>-R(--replace) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : \uc0c8\ub85c\uc6b4 \uaddc\uce59\uc73c\ub85c \ub300\uccb4<br \/>-I(--insert) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: \uccb4\uc778 \uac00\uc7a5 \ucc98\uc74c\uc5d0 \uaddc\uce59 \ucd94\uac00<br \/>-E(--rename-chain) &nbsp; &nbsp; &nbsp;: \uccb4\uc778 \uc774\ub984\uc744\ubcc0\uacbd<br \/><\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ucd9c\ucc98: http:\/\/blog.naver.com\/alice_k106\/221305928714\u25a0 iptables \uac1c\ub150 : \ud14c\uc774\ube14\uacfc \uccb4\uc778iptables\uc5d0\ub294 \ud14c\uc774\ube14(Table)\uacfc \uccb4\uc778(Chain) \uc774\ub77c\ub294 \ud070 \ubd84\ub958\uac00 \uc788\uc73c\uba70, \uadf8 \uc548\uc5d0 \uaddc\uce59\uc744 \uc815\uc758\ud574 \ud328\ud0b7\uc758 \ud750\ub984\uc744 \uc81c\uc5b4\ud55c\ub2e4. \ud14c\uc774\ube14\uc740 iptables\uc758 \uaddc\uce59\uc744 \uc815\uc758\ud560 \uc218 \uc788\ub294 \uac00\uc7a5 \uad11\ubc94\uc704\ud55c \ubc94\uc8fc\ub85c, \uc544\ub798\uc758 4\uac00\uc9c0 \uc885\ub958\uac00 \uc788\ub2e4. 1filternatmangleraw\uc774 \uc911\uc5d0\uc11c filter\ub294 \ub2e8\uc5b4\uac00 \uc758\ubbf8\ud558\ub294 \ub73b \uadf8\ub300\ub85c \ud328\ud0b7\uc744 \uac78\ub7ec\ub0b4\ub294 \uc6a9\ub3c4\uc774\uba70, Inbound(\ud638\uc2a4\ud2b8\ub85c \ub4e4\uc5b4\uc624\ub294 \ud328\ud0b7) \/ Outbound(\ud638\uc2a4\ud2b8\uc5d0\uc11c \ubc16\uc73c\ub85c \ub098\uac00\ub294 \ud328\ud0b7) \ubc0f Forward(\ud638\uc2a4\ud2b8\ub97c \uac70\uccd0\uac00\ub294 \ud328\ud0b7) [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1048","post","type-post","status-publish","format-standard","hentry","category-computing_security"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1048"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1048\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}