UDPを使用する軽量ファイル転送にTFTPがある。 TFTPはポート番号69番を使用するのは既知の通り。
TFTPは,サーバ側で指定したディレクトリにあるファイルしか転送することはできない。 今回,サーバ側へ送る先とサーバ側から持ってくる場所が異なる事案が発生した。
ということで,TFTPサーバを二つ動かしたい。基本的にはTFTPが待ち受けるポート番号を変えられればできるはず。
ということで,試してみた。
TFTPはtftp-hpaを使用しているので,ソースを眺めてみる。 IPPORT_TFTPが69で指定されているので,これを変えてみる。
次にTFTPはxinetd経由で起動しているので,xinetd.dディレクトリのtftpをコピーしtftp10069という名前で新しいポート番号のtftpを動作させてみる。
# default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp10069 { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd10069 server_args = -s /home/TFTP disable = no per_source = 11 cps = 100 2 flags = IPv4 }
起動用の定義をしたら,xinetdを再起動する。
# /etc/init.d/xinetd restart
待ち受けポートが開いているかチェックする。
# netstat -a --inet Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN udp 0 0 192.168.1.1:10242 *:* udp 0 0 192.168.104.11:10411 *:* udp 0 0 *:tftp *:* #
しかし指定したポートが待ち受けポートになっていない。
ここでしばらく悩む. . . . . . . . . . あっ!
/etc/servicesにポート番号を登録するんだった。
変更前
: bootpc 68/tcp dhcpc # BOOTP client bootpc 68/udp dhcpc tftp 69/tcp tftp 69/udp gopher 70/tcp # Internet Gopher gopher 70/udp :
変更後
: bootpc 68/tcp dhcpc # BOOTP client bootpc 68/udp dhcpc tftp 69/tcp tftp 69/udp tftp10069 10069/tcp tftp10069 10069/udp gopher 70/tcp # Internet Gopher gopher 70/udp :
再度xinetdを再起動して無事起動。
# default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp10069 { socket_type = dgram protocol = udp port = 10069 wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /home/TFTP disable = no per_source = 11 cps = 100 2 flags = IPv4 }
tftpプログラムはそのままで、xinetdの待ち受けポートをxinetdのtftp10069の設定ファイルに追加してみた。
servicesは既に追加してあるので,xinetdの再起動してみたら、69番と10069番でtftpが動作しているもよう。