{"id":31,"date":"2024-12-01T07:59:07","date_gmt":"2024-12-01T07:59:07","guid":{"rendered":"http:\/\/211.230.203.47\/wordpress\/?p=31"},"modified":"2024-12-01T07:59:20","modified_gmt":"2024-12-01T07:59:20","slug":"buntu%ec%97%90%ec%84%9c-ip-%ec%a3%bc%ec%86%8c%ea%b0%80-dhcp%eb%a1%9c-%eb%b3%80%ea%b2%bd%eb%90%a0-%eb%95%8c-%eb%b3%80%ea%b2%bd%eb%90%9c-ip%eb%a5%bc-%ea%b0%90%ec%a7%80%ed%95%98%ea%b3%a0-%ec%9d%b4","status":"publish","type":"post","link":"https:\/\/www.soon7shop.kr\/wordpress\/?p=31","title":{"rendered":"Ubuntu\uc5d0\uc11c IP \uc8fc\uc18c\uac00 DHCP\ub85c \ubcc0\uacbd\ub420 \ub54c \ubcc0\uacbd\ub41c IP\ub97c \uac10\uc9c0\ud558\uace0 \uc774\uba54\uc77c\ub85c \uc54c\ub9bc"},"content":{"rendered":"<p>Ubuntu\uc5d0\uc11c IP \uc8fc\uc18c\uac00 DHCP\ub85c \ubcc0\uacbd\ub420 \ub54c \ubcc0\uacbd\ub41c IP\ub97c \uac10\uc9c0\ud558\uace0 \uc774\uba54\uc77c\ub85c \uc54c\ub9bc\uc744 \ubcf4\ub0b4\ub294 Bash \uc2a4\ud06c\ub9bd\ud2b8\ub97c \ub9cc\ub4e4\uae30 \uc704\ud574 \ub2e4\uc74c\uc744 \uc218\ud589\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc740 \ud544\uc694\ud55c \uc2a4\ud06c\ub9bd\ud2b8\uc640 \uc124\uc815 \ub2e8\uacc4\uc785\ub2c8\ub2e4.<\/p>\n<h3>\uc2a4\ud06c\ub9bd\ud2b8 \uc791\uc131<\/h3>\n<p>\ub2e4\uc74c\uc740 \ubc31\uadf8\ub77c\uc6b4\ub4dc\uc5d0\uc11c \uc2e4\ud589\ub418\uba70, IP\uac00 \ubcc0\uacbd\ub420 \ub54c \uc54c\ub9bc\uc744 \ubcf4\ub0b4\ub294 Bash \uc2a4\ud06c\ub9bd\ud2b8\uc785\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\"><\/div>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<p>#!\/bin\/bash<\/p>\n<p># \uc774\uc804 IP\ub97c \uc800\uc7a5\ud560 \ud30c\uc77c \uacbd\ub85c<br \/>\nPREVIOUS_IP_FILE=&#8221;\/tmp\/previous_ip.txt&#8221;<br \/>\n# \uba54\uc77c \uc124\uc815<br \/>\nTO_EMAIL=&#8221;your_email@example.com&#8221;<br \/>\nSMTP_SERVER=&#8221;smtp.example.com&#8221;<br \/>\nSMTP_PORT=587<br \/>\nSMTP_USER=&#8221;your_email@example.com&#8221;<br \/>\nSMTP_PASS=&#8221;your_password&#8221;<\/p>\n<p># IP\ub97c \ud655\uc778\ud558\ub294 \ud568\uc218<br \/>\nget_current_ip() {<br \/>\nhostname -I | awk &#8216;{print $1}&#8217;<br \/>\n}<\/p>\n<p># \uc774\uba54\uc77c \ubcf4\ub0b4\uae30<br \/>\nsend_email() {<br \/>\nlocal new_ip=$1<br \/>\necho -e &#8220;Subject: IP Address Changed\\n\\nYour new IP address is: $new_ip&#8221; | \\<br \/>\ncurl &#8211;url &#8220;smtp:\/\/${SMTP_SERVER}:${SMTP_PORT}&#8221; \\<br \/>\n&#8211;ssl \\<br \/>\n&#8211;mail-from &#8220;$SMTP_USER&#8221; \\<br \/>\n&#8211;mail-rcpt &#8220;$TO_EMAIL&#8221; \\<br \/>\n&#8211;user &#8220;$SMTP_USER:$SMTP_PASS&#8221;<br \/>\n}<\/p>\n<p># \ucd08\uae30\ud654: \uc774\uc804 IP \ubd88\ub7ec\uc624\uae30<br \/>\nif [[ -f &#8220;$PREVIOUS_IP_FILE&#8221; ]]; then<br \/>\nprevious_ip=$(cat &#8220;$PREVIOUS_IP_FILE&#8221;)<br \/>\nelse<br \/>\nprevious_ip=&#8221;&#8221;<br \/>\nfi<\/p>\n<p># \ubb34\ud55c \ub8e8\ud504<br \/>\nwhile true; do<br \/>\n# \ud604\uc7ac IP \ud655\uc778<br \/>\ncurrent_ip=$(get_current_ip)<\/p>\n<p># IP \ubcc0\uacbd \uc5ec\ubd80 \ud655\uc778<br \/>\nif [[ &#8220;$current_ip&#8221; != &#8220;$previous_ip&#8221; ]]; then<br \/>\necho &#8220;IP \ubcc0\uacbd\ub428: $current_ip&#8221;<br \/>\necho &#8220;$current_ip&#8221; &gt; &#8220;$PREVIOUS_IP_FILE&#8221;<br \/>\nsend_email &#8220;$current_ip&#8221;<br \/>\nprevious_ip=&#8221;$current_ip&#8221;<br \/>\nfi<\/p>\n<p># 5\ubd84 \ub300\uae30<br \/>\nsleep 300<br \/>\ndone<\/p>\n<p><code class=\"!whitespace-pre hljs language-bash\"><br \/>\n<\/code><\/p>\n<\/div>\n<\/div>\n<hr \/>\n<h3>\uc2a4\ud06c\ub9bd\ud2b8 \uc2e4\ud589 \uc124\uc815<\/h3>\n<ol>\n<li><strong>\uc2a4\ud06c\ub9bd\ud2b8 \uc800\uc7a5 \ubc0f \uc2e4\ud589 \uad8c\ud55c \ubd80\uc5ec<\/strong><br \/>\n\uc704 \uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc608\ub97c \ub4e4\uc5b4 <code>\/home\/youruser\/ip_monitor.sh<\/code>\ub85c \uc800\uc7a5\ud569\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">chmod<\/span> +x \/home\/youruser\/ip_monitor.sh<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li><strong>\uc2a4\ud06c\ub9bd\ud2b8\ub97c \ubc31\uadf8\ub77c\uc6b4\ub4dc\uc5d0\uc11c \uc2e4\ud589<\/strong><br \/>\n<code>nohup<\/code> \uba85\ub839\uc5b4\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc2a4\ud06c\ub9bd\ud2b8\ub97c \ubc31\uadf8\ub77c\uc6b4\ub4dc\uc5d0\uc11c \uc2e4\ud589\ud569\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">nohup<\/span> \/home\/youruser\/ip_monitor.sh &amp;<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li><strong>\uc2dc\uc2a4\ud15c \uc7ac\ubd80\ud305 \uc2dc \uc790\ub3d9 \uc2e4\ud589 \uc124\uc815<\/strong><br \/>\ncrontab\uc5d0 \ucd94\uac00\ud569\ub2c8\ub2e4:<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\">crontab -e<br \/>\n<\/code><\/div>\n<\/div>\n<p>\uc544\ub798 \uc904 \ucd94\uac00:<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\">@reboot \/home\/youruser\/ip_monitor.sh &amp;<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\ud544\uc694\ud55c \ud328\ud0a4\uc9c0 \uc124\uce58<\/h3>\n<p>\uc774\uba54\uc77c\uc744 \ubcf4\ub0b4\uae30 \uc704\ud574 <code>curl<\/code> \uba85\ub839\uc5b4\ub97c \uc0ac\uc6a9\ud558\ubbc0\ub85c \ud574\ub2f9 \ud328\ud0a4\uc9c0\uac00 \uc124\uce58\ub418\uc5b4 \uc788\ub294\uc9c0 \ud655\uc778\ud558\uc138\uc694:<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\">sudo apt update<br \/>\nsudo apt install curl<br \/>\n<\/code><\/div>\n<\/div>\n<p>SMTP \uc815\ubcf4\ub294 \uc678\ubd80 POP3 \uba54\uc77c \uc11c\ubc84 (\uc608: Gmail, Naver \ub4f1)\uc5d0 \ub9de\uac8c \uc124\uc815\ud574\uc57c \ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 Gmail\uc744 \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0 SMTP \uc11c\ubc84\ub97c <code>smtp.gmail.com<\/code>\uc73c\ub85c \uc124\uc815\ud558\uc138\uc694. (\ucd94\uac00 \uc124\uc815\uc774 \ud544\uc694\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4: <a target=\"_new\" rel=\"noopener\">\uad6c\uae00 \uc571 \ube44\ubc00\ubc88\ud638<\/a>)<\/p>\n<p>\uc774 \uc2a4\ud06c\ub9bd\ud2b8\ub294 \ub124\ud2b8\uc6cc\ud06c \uc0c1\ud0dc\ub97c \uc8fc\uae30\uc801\uc73c\ub85c \ud655\uc778\ud558\uba70, \ubcc0\uacbd \uc0ac\ud56d\uc774 \ubc1c\uc0dd\ud560 \uacbd\uc6b0 \uc989\uc2dc \uc54c\ub9bc\uc744 \ubcf4\ub0c5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu\uc5d0\uc11c IP \uc8fc\uc18c\uac00 DHCP\ub85c \ubcc0\uacbd\ub420 \ub54c \ubcc0\uacbd\ub41c IP\ub97c \uac10\uc9c0\ud558\uace0 \uc774\uba54\uc77c\ub85c \uc54c\ub9bc\uc744 \ubcf4\ub0b4\ub294 Bash \uc2a4\ud06c\ub9bd\ud2b8\ub97c \ub9cc\ub4e4\uae30 \uc704\ud574 \ub2e4\uc74c\uc744 \uc218\ud589\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc740 \ud544\uc694\ud55c \uc2a4\ud06c\ub9bd\ud2b8\uc640 \uc124\uc815 \ub2e8\uacc4\uc785\ub2c8\ub2e4. \uc2a4\ud06c\ub9bd\ud2b8 \uc791\uc131 \ub2e4\uc74c\uc740 \ubc31\uadf8\ub77c\uc6b4\ub4dc\uc5d0\uc11c \uc2e4\ud589\ub418\uba70, IP\uac00 \ubcc0\uacbd\ub420 \ub54c \uc54c\ub9bc\uc744 \ubcf4\ub0b4\ub294 Bash \uc2a4\ud06c\ub9bd\ud2b8\uc785\ub2c8\ub2e4. bash #!\/bin\/bash # \uc774\uc804 IP\ub97c \uc800\uc7a5\ud560 \ud30c\uc77c \uacbd\ub85c PREVIOUS_IP_FILE=&#8221;\/tmp\/previous_ip.txt&#8221; # \uba54\uc77c \uc124\uc815 TO_EMAIL=&#8221;your_email@example.com&#8221; SMTP_SERVER=&#8221;smtp.example.com&#8221; SMTP_PORT=587 SMTP_USER=&#8221;your_email@example.com&#8221; SMTP_PASS=&#8221;your_password&#8221; # &hellip; <a href=\"https:\/\/www.soon7shop.kr\/wordpress\/?p=31\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Ubuntu\uc5d0\uc11c IP \uc8fc\uc18c\uac00 DHCP\ub85c \ubcc0\uacbd\ub420 \ub54c \ubcc0\uacbd\ub41c IP\ub97c \uac10\uc9c0\ud558\uace0 \uc774\uba54\uc77c\ub85c \uc54c\ub9bc&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":2,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":33,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions\/33"}],"wp:attachment":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}