路由器作為骨干網(wǎng)絡核心交換設備之一,在網(wǎng)絡中充當著網(wǎng)絡交通站的職責,它將網(wǎng)絡數(shù)據(jù)包通過既定規(guī)則進行轉(zhuǎn)發(fā)和交換,從而使網(wǎng)絡客戶端節(jié)點設備能有效使用網(wǎng)絡來進行信息的交換和交流。這樣,網(wǎng)絡中路由器相關的配置參數(shù)就成為了非常重要的網(wǎng)絡基礎資料之一。我單位企業(yè)網(wǎng)屬于中等規(guī)模廣域網(wǎng)范疇,下級接入路由器及匯聚層路由器有幾十臺之多。這些路由器一旦故障需要進行硬件更換時,路由器配置資料的查找總是讓人頭痛的問題之一,為此筆者使用
Linux系統(tǒng)提供的TFTP服務器及apache網(wǎng)頁服務器結合規(guī)劃配置了方便的路由資料備份系統(tǒng)解決以上問題。因為目前主流的Linux系統(tǒng)基本是由RedHat及Debian衍生出來的發(fā)行版。所以筆者分別就以上兩個
操作系統(tǒng)的配置進行敘述,希望能給其他用戶以幫助。
一、Debian下配置TFTP及apache服務器
?。ㄒ唬㏕FTP服務器配置
1、TFTP服務器組件安裝
在Debian中可以使用新立得軟件包管理器搜索tftpd-hpa軟件包,并勾選“標記以便安裝”選項,然后點擊應用按扭,系統(tǒng)將自動進行該組件包的安裝。用戶也可是直接再命令行下執(zhí)行apt-get install tftpd-hpa來進行安裝命令模式如下:
root@AkBirdofpreyWorkStation:~# apt-get install tftpd-hpa |
之后系統(tǒng)將創(chuàng)建相關的應用啟動腳本及配置文件,并會在跟目錄下創(chuàng)建/srv/tftp目錄。
2、TFTP配置文件及相關目錄權限修改
系統(tǒng)安裝完TFTP服務組件后,會自動創(chuàng)建TFTP服務需要的用戶組及配置文件,該文件為/etc/default/tftpd-hpa,初始配置內(nèi)容如下:
- # /etc/default/tftpd-hpa
- TFTP_USERNAME="tftp"
- TFTP_DIRECTORY="/srv/tftp"
- TFTP_ADDRESS="0.0.0.0:69"
- TFTP_OPTIONS="-secure"
|
我們需要將該文件修改為如下內(nèi)容:
- # /etc/default/tftpd-hpa
- TFTP_USERNAME="tftp"
- TFTP_DIRECTORY="/srv/tftp"
- TFTP_ADDRESS="0.0.0.0:69"
- TFTP_OPTIONS="-l -c -secure"
|
其中在TFTP_OPTIONS選項中加入了-l -c參數(shù),這樣當我們使用路由器參數(shù)備份命令時,可以將文件順利的上傳之TFTP服務器目錄。
于此同時我們需要修改TFTP服務器指定目錄的用戶及屬組,命令模式如下:
root@AkBirdofpreyWorkStation:/etc/default# chown tftp:tftp /srv/tftp |
這樣/srv/tftp目錄的屬組就修改為了tftp用戶,修改用戶屬組必須要進行,筆者測試中發(fā)現(xiàn),TFTP服務組件安裝后/srv/tftp目錄的屬組為root,如果不進行用戶屬組修改時,當使用路由器參數(shù)備份命令時,服務器將會出現(xiàn)transfer time out錯誤。
此時只要使用/etc/init.d/tftpd-hpa restart重啟TFTP服務,TFTP服務器應該就可以正常使用了,命令模式如下:
- root@AkBirdofpreyWorkStation:/etc/default# /etc/init.d/tftpd-hpa restart
- [ ok ] Restarting HPA's tftpd: in.tftpd.
|
我們需要將它修改為如下內(nèi)容:
- <VirtualHost *:80>
- ServerAdmin webmaster@localhost
- #DocumentRoot /var/www
- DocumentRoot /srv/tftp
- <Directory />
- Options FollowSymLinks Indexes
- AllowOverride All
- <limit GET POST OPTIONS PROPFIND>
- Order allow,deny
- Allow from all
- </Limit>
- </Directory>
- #<Directory /var/www/>
- #<Directory /var/www/>
- #Options Indexes FollowSymLinks MultiViews
- #AllowOverride None
- #Order allow,deny
- #allow from all
- #</Directory>
- ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
- <Directory "/usr/lib/cgi-bin">
- AllowOverride None
- Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
- Order allow,deny
- Allow from all
- </Directory>
- ErrorLog ${APACHE_LOG_DIR}/error.log
- # Possible values include: debug, info, notice, warn, error, crit,
- # alert, emerg.
- LogLevel warn
- CustomLog ${APACHE_LOG_DIR}/access.log combined
- </VirtualHost>
|
使用vi命令編輯/srv/tftp/.htaccess文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# vi /srv/tftp/.htaccess |
文件內(nèi)容如下:
AuthUserFile /etc/secure.user ##用戶帳號密碼文件名
AuthName akcwdCA 用戶登錄認證信息提示
AuthType Basic
- <Limit GET>
- require valid-user
- </Limit>
|
使用htpasswd -c /etc/secure.user建立用戶密碼文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# htpasswd -c /etc/secure.user user1 |
程序會提示你輸入兩次用戶的口令,然后用戶密碼文件就已經(jīng)創(chuàng)建,user1這個用戶也同時創(chuàng)建完成了。
使用命令/etc/init.d/apache2 restart重啟apache服務器,命令模式如下:
- root@AkBirdofpreyWorkStation:/# /etc/init.d/apache2 restart
- [....] Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
- ... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
- . ok
|
?。ǘ゛pache服務器服務器配置
1、apache服務器服務器組件安裝
該組件安裝和TFTP服務組件安裝差別不大,用戶可以選擇圖形界面或者命令行界面進行安裝即可
2、apache服務器服務器配置
因為之前筆者一直較多的使用RedHat及其衍生Linux版本。使用Debian/Linux系統(tǒng)后發(fā)現(xiàn)apache服務器配置文件與RedHat及其衍生Linux版本apache服務器配置文件差別很大,Debian/Linux系統(tǒng)的apache服務器配置文件沒有被集中在像httpd.conf文件中,而是被分別放置在了不同的配置文件里。因為路由器資料涉及到安全性問題,因此我們配置的apache服務器訪問時需要進行用戶安全審核,下面我們來做具體配置。
Debian/Linux系統(tǒng)的apache服務器配置文件保存在/etc/apache2中,使用vi /etc/apache2/apache2.conf查看幫助中的對該目錄結構對應配置文件的說明,我們需要修改的配置文件為 /etc/apache2/sites-enabled/000-default,該文件實際才是apache用戶定義的配置文件,其中包括服務器目錄以及訪問權限等內(nèi)容,初始配置文件為如下內(nèi)容:
- <VirtualHost *:80>
- ServerAdmin webmaster@localhost
- DocumentRoot /var/www
- <Directory />
- Options FollowSymLinks Indexes
- AllowOverride None
- </Directory>
- <Directory /var/www/>
- <Directory /var/www/>
- Options Indexes FollowSymLinks MultiViews
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
- ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
- <Directory "/usr/lib/cgi-bin">
- AllowOverride None
- Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
- Order allow,deny
- Allow from all
- </Directory>
- ErrorLog ${APACHE_LOG_DIR}/error.log
- # Possible values include: debug, info, notice, warn, error, crit,
- # alert, emerg.
- LogLevel warn
- CustomLog ${APACHE_LOG_DIR}/access.log combined
- </VirtualHost>
|
我們需要將它修改為如下內(nèi)容:
- <VirtualHost *:80>
- ServerAdmin webmaster@localhost
- #DocumentRoot /var/www
- DocumentRoot /srv/tftp
- <Directory />
- Options FollowSymLinks Indexes
- AllowOverride All
- <limit GET POST OPTIONS PROPFIND>
- Order allow,deny
- Allow from all
- </Limit>
- </Directory>
- #<Directory /var/www/>
- #<Directory /var/www/>
- #Options Indexes FollowSymLinks MultiViews
- #AllowOverride None
- #Order allow,deny
- #allow from all
- #</Directory>
- ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
- <Directory "/usr/lib/cgi-bin">
- AllowOverride None
- Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
- Order allow,deny
- Allow from all
- </Directory>
- ErrorLog ${APACHE_LOG_DIR}/error.log
- # Possible values include: debug, info, notice, warn, error, crit,
- # alert, emerg.
- LogLevel warn
- CustomLog ${APACHE_LOG_DIR}/access.log combined
- </VirtualHost>
|
使用vi命令編輯/srv/tftp/.htaccess文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# vi /srv/tftp/.htaccess |
文件內(nèi)容如下:
AuthUserFile /etc/secure.user ##用戶帳號密碼文件名
AuthName akcwdCA 用戶登錄認證信息提示
AuthType Basic
- <Limit GET>
- require valid-user
- </Limit>
|
使用htpasswd -c /etc/secure.user建立用戶密碼文件,命令模式如下:
root@AkBirdofpreyWorkStation:/# htpasswd -c /etc/secure.user user1 |
程序會提示你輸入兩次用戶的口令,然后用戶密碼文件就已經(jīng)創(chuàng)建,user1這個用戶也同時創(chuàng)建完成了。
使用命令/etc/init.d/apache2 restart重啟apache服務器,命令模式如下:
- root@AkBirdofpreyWorkStation:/# /etc/init.d/apache2 restart
- [....] Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
- ... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.253 for ServerName
- . ok
|