<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">집에두고 사용하는 라즈베리파이 서버의 네트워크 연결을 유선에서 무선으로 변경하였습니다.</p>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">유선으로 사용하면 랜선이 닿을 수 있는 거리에 있어야하는 제약도 생기고 연결되는 선이 많아지니 뭔가 지저분했는데, 무선 환경으로 변경한 다음 그런 부분들이 모두 해소되니 아주 만족스럽습니다. 네트워크 속도는 유선보다 안좋아지긴 했을텐데 제가 사용하는 환경에서 크게 체감될 정도는 아니네요.</p>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8; text-align: center; clear: none; float: none;"><img src="https://t1.daumcdn.net/cfile/tistory/99BDFC415E88A0F90F" style="box-sizing: border-box; border: 0px; vertical-align: middle;" /></p>
<h3 style="box-sizing: border-box; font-size: 1em; margin: 0px; padding: 0px; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; background-color: #f8f8f8;">간헐적 WiFi 접속해제</h3>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">무선환경에서 만족스럽게 사용하던 중 간헐적으로 WiFi 네트워크가 끊겨있는 문제가 있었습니다. 정확한 원인은 잘 모르겠으나 WiFi가 끊길때마다 물리적으로 라즈베리파이를 직접 만져서 해결해줘야 하는 부분이 불편하게 느껴져서 해결 방법을 찾아봤습니다.</p>
<h3 style="box-sizing: border-box; font-size: 1em; margin: 0px; padding: 0px; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; background-color: #f8f8f8;">WiFi 자동 재접속 스크립트</h3>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">해결 솔루션을 찾기 위해서 구글링을 하다가 너무 좋은 해결책을 제시해 주는 블로그 글을 발견했습니다.</p>
<div class="opengraph" data-opengraph-image="" data-opengraph-title="Automatically reconnecting WiFi on a RaspberryPi - alexba.in" data-opengraph-description="In this post, I’m going to cover writing a short script that automatically reconnects a RaspberryPi to a WiFi network. The script will check to …" data-opengraph-host="alexba.in" data-opengraph-url="http://alexba.in/blog/2015/01/14/automatically-reconnecting-wifi-on-a-raspberrypi/" style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8; position: relative; height: 100px; box-shadow: rgb(153, 153, 153) 0px 1px 5px; margin: 10px auto 30px; overflow: hidden;">
   <div style="box-sizing: border-box; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; padding: 10px;"><a href="http://alexba.in/blog/2015/01/14/automatically-reconnecting-wifi-on-a-raspberrypi/" style="box-sizing: border-box; background-color: transparent; color: #666666; text-decoration-line: none; display: block; font-size: 18px; overflow: hidden; overflow-wrap: break-word; line-height: 25px; text-overflow: ellipsis; white-space: nowrap;" target="_blank">Automatically reconnecting WiFi on a RaspberryPi - alexba.in</a>
      <div style="box-sizing: border-box; font-size: 12px; line-height: 18px; height: 36px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-overflow: ellipsis; display: -webkit-box; overflow: hidden; color: #666666;">In this post, I’m going to cover writing a short script that automatically reconnects a RaspberryPi to a WiFi network. The script will check to …</div>
      <div style="box-sizing: border-box; font-size: 11px; color: #999999; line-height: 14px;">alexba.in</div>
      </div>
   </div>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">길게 내용이 기록되어있지만 간단히 설명하자면,</p>
<ol style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">
   <li style="box-sizing: border-box;">WiFi 연결상태를 점검하여 연결이 되어있지 않으면 Wlan을 종료했다 재기동하여 저장된 네트워크에 자동으로 재접속하도록 스크립트를 작성</li>
   <li style="box-sizing: border-box;">Crontab으로 등록하여 5분주기로 스크립트를 실행</li>
   </ol>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">제가 작업한 순서를 기록해 봅니다.</p>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">1. 실행할 스크립트 파일을 생성</p>
<pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 16px; color: #555555; background-color: #f8f8f8;">
   <code class="hljs ruby" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 0.85em; padding: 0.5em; color: black; background: rgb(255, 255, 255); border-radius: 4px; display: block; overflow-x: auto;">pi@raspberrypi<span class="hljs-symbol" style="box-sizing: border-box; color: #1c00cf;">:~</span> $ sudo nano /usr/local/bin/wifi_rebooter.sh</code>
   </pre>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">2. 스크립트 내용 작성 후 저장(Nano 에디터 저장은 Ctrl+X, Y 순서 입력)</p>
<pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 16px; color: #555555; background-color: #f8f8f8;">
   <code class="hljs bash" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 0.85em; padding: 0.5em; color: black; background: rgb(255, 255, 255); border-radius: 4px; display: block; overflow-x: auto;"><span class="hljs-meta" style="box-sizing: border-box; color: #643820;">#!/bin/bash
</span><span class="hljs-comment" style="box-sizing: border-box; color: #007400;"># The IP for the server you wish to ping (8.8.8.8 is a public Google DNS server)</span>
SERVER=8.8.8.8
<span class="hljs-comment" style="box-sizing: border-box; color: #007400;"># Only send two pings, sending output to /dev/null</span>
ping -c2 <span class="hljs-variable" style="box-sizing: border-box; color: #3f6e74;">${SERVER}</span> &gt; /dev/null
<span class="hljs-comment" style="box-sizing: border-box; color: #007400;"># If the return code from ping ($?) is not 0 (meaning there was an error)</span><span class="hljs-keyword" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">if</span> [ $? != 0 ]
<span class="hljs-keyword" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">then</span><span class="hljs-comment" style="box-sizing: border-box; color: #007400;"># Restart the wireless interface</span>
    ifdown --force wlan0
    ifup wlan0
<span class="hljs-keyword" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">fi</span></code>
   </pre>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">3. 작성한 스크립트 실행권한 등록</p>
<pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 16px; color: #555555; background-color: #f8f8f8;">
   <code class="hljs perl" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 0.85em; padding: 0.5em; color: black; background: rgb(255, 255, 255); border-radius: 4px; display: block; overflow-x: auto;">sudo <span class="hljs-keyword" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">chmod</span> +<span class="hljs-keyword" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">x</span> /usr/<span class="hljs-keyword" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">local</span>/bin/wifi_rebooter.sh</code>
   </pre>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">4. Crontab에 5분주기 등록을 위해 에디터로 열기</p>
<pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 16px; color: #555555; background-color: #f8f8f8;">
   <code class="hljs nginx" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 0.85em; padding: 0.5em; color: black; background: rgb(255, 255, 255); border-radius: 4px; display: block; overflow-x: auto;"><span class="hljs-attribute" style="box-sizing: border-box; font-weight: bold; color: #aa0d91;">sudo</span> nano /etc/crontab</code>
   </pre>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">5. crontab 맨 마지막줄에 아래내용 기록 후 저장(Nano 에디터 저장은 Ctrl+X, Y 순서 입력)</p>
<pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 16px; color: #555555; background-color: #f8f8f8;">
   <code class="hljs markdown" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 0.85em; padding: 0.5em; color: black; background: rgb(255, 255, 255); border-radius: 4px; display: block; overflow-x: auto;"><span class="hljs-emphasis" style="box-sizing: border-box; font-style: italic;">*/5 *</span><span class="hljs-bullet" style="box-sizing: border-box; color: #1c00cf;">* *</span> *   root    /usr/local/bin/wifi_rebooter.sh</code>
   </pre>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">6. 스크립트 테스트<br style="box-sizing: border-box;" />&nbsp; &nbsp;강제로 wlan을 죽인 다음에 5분후에 네트워크가 연결되고 있는지 확인합니다.<br style="box-sizing: border-box;" />&nbsp; &nbsp;스크립트와 crontab이 잘 동작하고 있다면 다시 네트워크가 연결되어 있을겁니다.</p>
<pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 16px; color: #555555; background-color: #f8f8f8;">
   <code class="hljs ruby" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 0.85em; padding: 0.5em; color: black; background: rgb(255, 255, 255); border-radius: 4px; display: block; overflow-x: auto;">pi@raspberrypi<span class="hljs-symbol" style="box-sizing: border-box; color: #1c00cf;">:~</span> $sudo ifdown --force wlan<span class="hljs-number" style="box-sizing: border-box; color: #1c00cf;">0</span></code>
   </pre>
<p style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">모든 작업을 끝냈음에도 WiFi 자동재접속이 동작하지 않는다면, 작업했던 단계 중 빠진 부분이 있는지 다시한번 확인하시면 될 것 같습니다. 제가 참고한 블로그의 원문을 한번 더 살펴보셔도 되고요.</p>
<p><br style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;" /><br style="box-sizing: border-box; color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;" /><span style="color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">출처:&nbsp;</span><a href="https://signpen.net/2511036" style="box-sizing: border-box; background-color: #f8f8f8; color: #222222; text-decoration-line: none; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px;" target="_blank">https://signpen.net/2511036</a><span style="color: #555555; font-family: &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, 굴림, gulim, 돋움, dotum, &quot;Microsoft NeoGothic&quot;, &quot;Droid sans&quot;, sans-serif; font-size: 16px; background-color: #f8f8f8;">&nbsp;[싸인펜의 Life Log]</span></p>