カテゴリ:

今回はIOSでのFTPの利用を確認します。R1のF0/1のIPアドレスは192.168.0.100で、FTPサーバは192.168.0.180です。

R1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            12.12.12.1      YES manual up                    up
FastEthernet0/1            192.168.0.100   YES manual up                    up

まず何も設定していない状態で利用してみます。下記はR1のstartup-configをFTPサーバにコピーする例ですが、失敗しています。

R1#copy startup-config ftp:
Address or name of remote host []? 192.168.0.180
Destination filename [r1-confg]?
Writing r1-confg
%Error opening ftp://192.168.0.180/r1-confg (Permission denied)

FTPサーバでのログ(/var/log/vsftpd.log)はこのようになりました。ユーザ名がftp、パスワードはrouter@cisco.coとなっています。ユーザ名がftpまたはanonymousである場合はアノニマス(匿名)FTPといい、誰もがログイン可能な設定です。この時、パスワードはチェックされないので何を入れても大丈夫です。ただしアノニマスFTPではセキュリティ上、ダウンロードのみが許可されアップロードは許可されないのが一般的な設定です。この理由より、コピーは失敗しました。

Wed May  4 16:15:14 2011 [pid 18496] CONNECT: Client "192.168.0.100"
Wed May  4 16:15:14 2011 [pid 18495] [ftp] OK LOGIN: Client "192.168.0.100", anon password "router@cisco.co"

今度は逆にFTPサーバ上のファイル(orange)をflashにダウンロードしてみます。問題なく利用出来ることが分かります。

R1#copy ftp: flash:
Address or name of remote host []?
192.168.0.180
Source filename []? orange
Destination filename [orange]?
Accessing ftp://192.168.0.180/orange...
Erase flash: before copying? [confirm]
Erasing the flash filesystem will remove all files! Continue? [confirm]
Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...erased
Erase of flash: complete
Loading orange
[OK - 12/4096 bytes]

Verifying checksum...  OK (0x3E66)
12 bytes copied in 0.144 secs (83 bytes/sec)

R1#more flash:orange
Hello! IOS.

ユーザ名を指定してFTPを利用するには予めユーザ名とパスワードを設定します。FTPサーバにはユーザ名cisco、パスワードciscoがすでに登録されています。

R1(config)#ip ftp username cisco
R1(config)#ip ftp password cisco

ここで最初に試してみたR1のstartup-configをFTPサーバに再度コピーしてみます。

R1#copy running-config ftp:
Address or name of remote host []? 192.168.0.180
Destination filename [r1-confg]?
Writing r1-confg !
1347 bytes copied in 4.276 secs (315 bytes/sec)

実行されました。FTPサーバのログをみるとユーザciscoでログインしていることが分かります。

Wed May  4 16:33:00 2011 [pid 18573] CONNECT: Client "192.168.0.100"
Wed May  4 16:33:00 2011 [pid 18572] [cisco] OK LOGIN: Client "192.168.0.100"
Wed May  4 16:33:00 2011 [pid 18574] [cisco] OK UPLOAD: Client "192.168.0.100", "/home/cisco/r1-confg", 1347 bytes, 68.91Kbyte/sec

念の為にFTPサーバにあるファイルを開いてみます。

# head -5 /home/cisco/r1-confg

!
! Last configuration change at 15:14:03 JST Wed May 4 2011
!
version 12.4

このようにFTPサーバが設定されていれば、コンフィグファイルのバックアップなどを簡単に取ることが可能です。