- TFTPサーバーを用意する.
- inetd.confのtftpサーバーの項目を設定
tftp dgram udp wait root /usr/local/sbin/tcpd /usr/sbin/in.tftpd -s /usr/local/tftproot
-
- /etc/hosts.allowにtftpアクセス許可を出す.
in.tftpd : スイッチのIPリスト
-
- tftpdのルートディレクトリ(/usr/local/tftproot)以下にあらかじめ空の設定ファイル(ホスト名.cfg)を作成し,書込み許可を出しておく.
- スイッチに書き込みを行わせるexpectスクリプト
#!/usr/bin/expect --
log_user 1
set tftpsrv "TFTPサーバー"
foreach host $argv {
spawn /usr/bin/telnet $host
expect "assword:" { send "パスワード\r" }
expect ">" {send "enable\r" }
expect "assword:" { send "パスワード\r" }
expect "#" {send "copy system:/running-config tftp:\r" }
expect "remote host" { send "$tftpsrv\r" }
expect "filename" { send "$host.cfg\r" }
expect "bytes copied" { send "quit\r" }
}
expect eof
#!/usr/bin/expect --
log_user 1
set tftpsrv "TFTPサーバー"
foreach host $argv {
spawn /usr/bin/telnet $host
expect "assword:" { send "パスワード\r" }
expect ">" {send "enable\r" }
expect "assword:" { send "パスワード\r" }
expect "(enable)" { send "write network\r" }
expect "IP address" { send "$tftpsrv\r" }
expect "Name of configuration" { send "$host.cfg\r" }
expect "Upload configuration" { send "y\r" }
expect "Finished" { send "quit\r" }
}
expect eof