레이블이 tftpboot인 게시물을 표시합니다. 모든 게시물 표시
레이블이 tftpboot인 게시물을 표시합니다. 모든 게시물 표시

2009년 12월 4일 금요일

맥에서 tftp 사용하기 (Using tftp on the Mac)

일반적으로 많이 쓰이지는 않아도 라우터등의 장비 펌웨어 업그레이드라던지 임베디드 보드 개발할 때 유용한 도구중에 하나가 tftp(trivial ftp)이다.
Mac OS X에도 역시 기본으로 포함되어 있지만 다른 daemon들과는 다르게 자동으로 실행하게 되어있지 않다. 그리고 실행하려면 직접 하면 안되고 꼭 launchd와 /System/Library/LaunchDaemon/tftp.plist를 사용해서 실행해야 한다.



실행하는 방법은 다음과 같다.

$ sudo launchctl
Password:
launchd% load -F /System/Library/LaunchDaemons/tftp.plist
launchd%

이제 아무 문제가 없으면 launchd가 tftp 포트를 listen하고 있다가 connection이 들어오면 tftp를 실행해주게 된다.

그리고 linux/unix의 경우 일반적으로 tftp 디렉토리는 /tftpboot 를 사용하지만 맥에서는 tftp.plist 파일에서 지정하게 되어 있고 디폴트로는 /private/tftpboot 디렉토리이다.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>com.apple.tftpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/tftpd</string>
<string>-i</string>
<string>-s</string>
<string>/private/tftpboot</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>tftp</string>
<key>SockType</key>
<string>dgram</string>
</dict>
</dict>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<true/>
</dict>
</dict>
</plist>

 
텍스트 에디터로 tftp.plist파일을 열어보면 내용은 위와 같다. 그 중 bold체로 된 부분을 변경해 주면 tftp 디렉토리를 원하는대로 바꿔줄 수 있다.

사용이 끝나 실행을 중단시키고 싶으면 실행할 때와 마찬가지로 launchctl에서 명령을 내려주면 된다.

launchd% unload /System/Library/LaunchDaemons/tftp.plist

만일 tftp를 부팅할 때 부터 계속 실행하도록 해 주고 싶으면 launchctl에서 다음의 명령을 사용한다.

launchd% load -w  /System/Library/LaunchDaemons/tftp.plist

또한 반대로 부팅할 때 부터 계속 실행되는걸 멈추고 싶으면 아래 명령을 사용하면 된다.

launchd% unload -w /System/Library/LaunchDaemons/tftp.plist