2012年9月11日 星期二

Squirrelmail postfix admin change password

Postfixadmin Squirellmail Plugins To Change Postfix User Password


What is Postfixadmin Squirellmail Plugins ?

This plugin is used to help postfix user to be able to change their password, autovacation and forwarding via squirellmail webmail without need to asking admin to change their needs.

Prepare anything to start

1. Zend Framework Minimal. We can download it from this URL http://framework.zend.com/releases/ZendFramework-1.10.8/ZendFramework-1....

2. We need to recompile / install php to support XMLRPC

3. We need to install PHP MDB2 library using PEAR

4. Download and Install postfixadmin-squirellmail plugins, we can download it via SVN command below :
#svn co  http://squirrelmail-postfixadmin.palepurple.co.uk/svn

I Assume we already have apache, php, mysql and webmail install and running properly in the server

Download and Copy Zend Framework Library to PHP Include Path

Note :
My php Include Path is stored in /usr/local/lib/php

Login into the server as root
#cd /root
#wget http://framework.zend.com/releases/ZendFramework-1.10.8/ZendFramework-1....
#tar -zxvf ZendFramework-1.10.8-minimal.tar.gz
#cd /root/ZendFramework-1.10.8-minimal/library
#mv Zend /usr/local/lib/php/

Recompile PHP to support PHP XMLRPC Extensions

Previously i have php-5.2.14 in my root directory, so i can just recompile it using the sources

#cd /root
#cd php-5.2.14
#./configure '--enable-fpm' '--enable-fastcgi' '--with-mcrypt' '--with-zlib' '--enable-mbstring' '--disable-debug' '--enable-inline-optimization' '--enable-sockets' '--enable-zip' '--with-curl' '--with-mysql=/usr/local' '--with-xmlrpc'
#make
#make install

Install PHP MDB2 Library Using PEAR

#pear install MDB2#mysql

Download and Install Postfixadmin-squirellmail plugins

#cd /root
#svn co  http://squirrelmail-postfixadmin.palepurple.co.uk/svn
#cd svn/tags
#mv squirrelmail-postfixadmin-0.4.3 /home/users1/webmail/plugins/postfixadmin

Edit the plugins

#cd /home/users1/webmail/plugins/postfixadmin
#cp config.php.sample config.php
#pico config.php

$CONF['database_type'] = 'mysql'; /* or mysql or other db as supported by MBD2 */
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'yourpostfixpassword';
$CONF['database_name'] = 'postfix';
$CONF['vacation_domain'] = 'autoreply.my.domain.com';
$AllowVacation = true;
$AllowChangePass = true;

Edit plugin function
sudo vim /usr/share/squirrelmail/plugins/postfixadmin/functions.inc.php

line 24: add 
ini_set('include_path',ini_get('include_path').':/usr/share/php:'); 

Configure Squirellmail Plugins

#cd /home/users1/webmail/config
#./conf.pl

Press 8 for plugins
You will see an Available Plugins there. Example if "postfixadmin" plugin is in number 2 then
Press 2 for postfixadmin
Press S for Save data
Press Q for Quit

Restart Your Webserver.

#/usr/local/apache/bin/apachectl stop
#/usr/local/apache/bin/apachectl start
Open your browser and try to access your webmail
Login into the webmail and click Options
You will see 3 new options there like : Auto Response, Forwarding and Change Password

Click Change Password
Input your old password
Input twice your new password.
Logout from squirellmail

2012年8月25日 星期六

使用 Ubuntu 安裝郵件伺服器 (Mail Server):Postfix + Dovecot + Openwebmail

使用 Ubuntu 安裝郵件伺服器 (Mail Server):Postfix + Dovecot + Openwebmail

在 DNS Server 的文章提到二個域名 (domain name):

    www.example.com.tw
    mail.example.com.tw

這篇文章的內容與 mail.example.com.tw 有關;至於 www.example.com.tw 上一篇已經說明。

架設郵件伺服器 (mail server) 需要 Postfix 和 Dovecot 二個套件。

    Postfix 負責 SMTP
    Dovecot 負責 POP3 和 IMAP

選擇 Dovecot 的理由是 Dovecot 同時支援 Maildir 和 mbox;而 Openwebmail 只支援 mbox。

Ubuntu Server 從 9.10 版開始提供一支套件 Dovecot-postfix,這支套件整合了 Postfix 與 Dovecot 的設定環境,使設定更簡單。

環境

我們希望郵件伺服器 Outlook Express 可以收發郵件,同時也提供網頁郵件服務。以下是我們的假設環境:

    郵件伺服器:Postfix
    POP3 伺服器:Dovecot-pop3d
    IMAP 伺服器:Dovecot-imapd
    信箱格式:mbox
    認證:使用 Ubuntu Server 的帳號及密碼
    網頁郵件服務:Openwebmail

Postfix

Ubuntu Server 常用的郵件伺服器是 Postfix。

安裝

安裝 Postfix 的指令如下:

    sudo apt-get install postfix

安裝過程中,畫面會要求你設定你的環境。

        Internet Site
        example.com.tw

啟動停止 Postfix 的指令如下:

    sudo /etc/init.d/postfix start #啟動 Postfix
    sudo /etc/init.d/postfix stop #停止 Postfix
    sudo /etc/init.d/postfix restart #重新啟動 Postfix

組態

後面我們要安裝 dovecot-postfix 套件,安裝 dovecot-postfix 會修改 Postfix 的 main.cf 檔案,這裡的 main.cf 檔案是被 dovecot-postfix 更改後的檔案。

Postfix 主要的組態設定檔是 /etc/postfix/main.cf。vi 編輯 main.cf 的指令如下:

    sudo vi /etc/postfix/main.cf

main.cf 的內容如下:

    第 9行 將 (Ubuntu) 拿掉
    第21行到第25行 #註記
    第34行 新增 mail.example.com.tw
    第41行 #註記,因為這裡使用 mbox
    第54行 #註記
    第56行到第61行 #註記

    # See /usr/share/postfix/main.cf.dist for a commented, more complete version
    
    
    # Debian specific: Specifying a file name will cause the first
    # line of that file to be used as the name. The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname
    
    smtpd_banner = $myhostname ESMTP $mail_name
    biff = no
    
    # appending .domain is the MUA's job.
    append_dot_mydomain = no
    
    # Uncomment the next line to generate "delayed mail" warnings
    #delay_warning_time = 4h
    
    readme_directory = no
    
    # TLS parameters
    #smtpd_tls_cert_file = /etc/ssl/certs/ssl-mail.pem
    #smtpd_tls_key_file = /etc/ssl/private/ssl-mail.key
    #smtpd_use_tls = yes
    #smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    #smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    
    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
    # information on enabling SSL in the smtp client.
    
    myhostname = dns.example.com.tw
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    mydestination = mail.example.com.tw, example.com.tw, dns.example.com.tw, localhost.example.com.tw, localhost
    relayhost =
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    
    #home_mailbox = Maildir/
    
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_type = dovecot
    smtpd_sasl_path = private/dovecot-auth
    smtpd_sasl_authenticated_header = yes
    smtpd_sasl_security_options = noanonymous
    smtpd_sasl_local_domain = $myhostname
    broken_sasl_auth_clients = yes
    
    smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    smtpd_sender_restrictions = reject_unknown_sender_domain
    
    #mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/conf.d/01-dovecot-postfix.conf -n -m "${EXTENSION}"
    
    #smtp_use_tls = yes
    #smtpd_tls_received_header = yes
    #smtpd_tls_mandatory_protocols = SSLv3, TLSv1
    #smtpd_tls_mandatory_ciphers = medium
    #smtpd_tls_auth_only = yes
    #tls_random_source = dev:/dev/urandom

重新啟動 Postfix。
Dovecot

Ubuntu Server 常用的 POP3 Server, IMAP Server 是 dovecot。

安裝

安裝 Dovecot POP3, IMAP Server 的指令如下:

    sudo apt-get install dovecot-pop3d dovecot-imapd

安裝 dovecot-postfix 的指令如下:

    sudo apt-get install dovecot-postfix

啟動停止 Dovecot 的指令如下:

    sudo /etc/init.d/dovecot start #啟動 Dovecot
    sudo /etc/init.d/dovecot stop #停止 Dovecot
    sudo /etc/init.d/dovecot restart #重新啟動 Dovecot

組態

安裝 dovecot-postfix 後,/etc/dovecot 目錄的 dovecot.conf 被 # 註記了。新的組態檔的位置在:

    Ubuntu Server 9.10 在 /etc/dovecot 目錄裡,多了 dovecot-postfix.conf 檔案。
    Ubuntu server 10.04 LTS 在 /etc/dovecot/conf.d 目錄裡,多了 01-dovecot-postfix.conf 檔案。

編輯組態檔案的指令如下:

    sudo vi /etc/dovecot/dovecot-postfix.conf # Ubuntu Server 9.10
    # or
    sudo vi /etc/dovecot/conf.d/01-dovecot-postfix.conf # Ubuntu Server 10.04 LTS

dovecot-postfix.conf 或 01-dovecot-postfix.conf 檔案內容如下:

    第 2行 將 imaps pop3s managesieve 用 # 註記
    第 3行 disable_plaintext_auth = no,使用 Ubuntu 帳號、密碼
    第 4行 ssl = no,不使用 SSL 認證
    第 5行到第 7行 #註記,不使用 SSL 認證
    第 8行 mail_location = maildir:~/Maildir #註記,不使用 Maildir
    第 9行 新增 mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox),使用 mbox

    # Some general options
    protocols = imap pop3 # imaps pop3s managesieve
    disable_plaintext_auth = no
    ssl = no
    #ssl_cert_file = /etc/ssl/certs/ssl-mail.pem
    #ssl_key_file = /etc/ssl/private/ssl-mail.key
    #ssl_cipher_list = ALL:!LOW:!SSLv2:ALL:!aNULL:!ADH:!eNULL:!EXP:RC4+RSA:+HIGH:+MEDIUM
    #mail_location = maildir:~/Maildir
    mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox)
    auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
    
    # IMAP configuration
    protocol imap {
    mail_max_userip_connections = 10
    imap_client_workarounds = outlook-idle delay-newmail
    }
    
    # POP3 configuration
    protocol pop3 {
    mail_max_userip_connections = 10
    pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
    }
    
    # LDA configuration
    protocol lda {
    postmaster_address = postmaster
    mail_plugins = sieve
    quota_full_tempfail = yes
    deliver_log_format = msgid=%m: %$
    rejection_reason = Your message to <%t> was automatically rejected:%n%r
    }
    
    # Plugins configuration
    plugin {
    sieve=~/.dovecot.sieve
    sieve_dir=~/sieve
    }

重新啟動 Dovecot。

測試

測試 SMTP port 25,輸入下列指令

    sudo telnet mail.example.com.tw 25

Postfix 回應顯示如下:

    Trying 192.168.0.10...
    Connected to dns.example.com.tw.
    Escape character is '^]'.
    220 dns.example.com.tw ESMTP Postfix

接著輸入下列指令

    ehlo mail.example.com.tw

Postfix 回應顯示如下:

第 5行 250-AUTH PLAIN LOGIN
第 6行 250-AUTH=PLAIN LOGIN

    250-dns.example.com.tw
    250-PIPELINING
    250-SIZE 10240000
    250-ETRN
    250-AUTH PLAIN LOGIN
    250-AUTH=PLAIN LOGIN
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN

完成收發信的認證設定。
Openwebmail

網頁郵件套件我們選擇 Openwebmail。

Ubuntu 沒有提供 Openwebmail 套件,B2D 中文 Linux 計劃1有提供。

修改 /etc/apt/sources.list

    sudo vi /etc/apt/sources.list

在 sources.list 檔案最後面加入以下這行

    deb ftp://debian.tnc.edu.tw/pub1 b2d/

Ubuntu Server 10.04 LTS 比較麻煩,套件庫裡的 libmd5-perl 有問題,無法直接安裝。手動安裝 libmd5-perl 的指令如下:

第 1行 下載 libmd5-perl_2.03-1_all.deb 套件。
第 2行 安裝 libmd5-perl_2.03-1_all.deb 套件。

    sudo wget http://mirrors.kernel.org/ubuntu/pool/universe/libm/libmd5-perl/libmd5-perl_2.03-1_all.deb
    sudo dpkg -i libmd5-perl_2.03-1_all.deb

安裝

安裝 Openwebmail 的指令如下:

    sudo apt-get update
    sudo apt-get install openwebmail

安裝後不要忘記將 /etc/apt/sources.list 檔案裡新增的 deb ftp://debian.tnc.edu.tw/pub1 b2d/ 註記起來。

    # deb ftp://debian.tnc.edu.tw/pub1 b2d/

更新 auth_unix.pl

B2D 版本已經是很舊的版本 (2006/10/20 以前的版本,但不包括 1020 版),因為當時尚未改成支援 blowfish,所以必須下載 auth_unix.pl,把它拷貝到 /usr/lib/cgi-bin/openwebmail/auth,覆蓋掉原有的 auth_unix.pl,否則將無法正常登入 Openwebmail。會出現下面的錯誤訊息。

    --------------------------------------------------------------------------------------------------------------
    Can't locate Crypt/Eksblowfish/Bcrypt.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl /usr/lib/cgi-bin/openwebmail) at /usr/lib/cgi-bin/openwebmail/auth/auth_unix.pl line 15.
    BEGIN failed--compilation aborted at /usr/lib/cgi-bin/openwebmail/auth/auth_unix.pl line 15.
    --------------------------------------------------------------------------------------------------------------

下載 auth_unix.pl 指令如下:

    sudo wget ftp://ftp3.tnc.edu.tw/b2d/openwebmail/auth_unix.pl

覆蓋掉原有的 auth_unix.pl 指令如下:

    sudo cp auth_unix.pl /usr/lib/cgi-bin/openwebmail/auth/

組態

登入 Openwebmail 前,先修改 openwebmail.conf 檔案,編輯 openwebmail.conf 指令如下:

    sudo vi /usr/lib/cgi-bin/openwebmail/etc/openwebmail.conf

openwebmail.conf 檔案內容如下:

    第13行 設定域名,這裡是 example.com.tw
    第15行 病毒檢查
    第16行 垃圾郵件檢查
    第17行 垃圾郵件學習
    第18行 網頁硬碟服務
    第19行 終端機功能
    第21行 郵件語系
    第22行 ICON 設定
    第25行到第29行 郵件簽名

    #
    # Open WebMail configuration file
    #
    # This file contains just the overrides from defaults/openwebmail.conf,
    # please make all changes to this file.
    #
    # This file sets options for all domains and all users.
    # To set options on per domain basis, please put them in sites.conf/domainname
    # To set options on per user basis, please put them in users.conf/username
    #
    # Please refer to openwebmail.conf.help for the description of each option
    #
    domainnames example.com.tw
    
    enable_viruscheck yes
    enable_spamcheck yes
    enable_learnspam yes
    enable_webdisk yes
    enable_sshterm no
    
    default_locale zh_TW.Big5
    default_iconset Cool3D.Chinese.Traditional
    default_fscharset none
    
    <default_signature>
    --
    Open WebMail Project (http://openwebmail.org)
    
    </default_signature>

記得在修改 openwebmail.conf 之後,別忘了執行

    sudo /usr/lib/cgi-bin/openwebmail/openwebmail-tool.pl --init

登入 Openwebmail

開啟瀏覽器,網址列輸入

    http://192.168.0.10/openwebmail

使用者第一次登入帳戶要設定基本資料。

2012年8月24日 星期五

Install Openwebmail

Install Openwebmail

http://maxding.blogspot.tw/2009/06/ubuntu-server-apachemysqlphpopenwebmail.html

http://openwebmail.org/openwebmail/download/doc/readme.txt

Note: Perl 5.12.4 not support

perl-suid not found!


cd /tmp

Go to this site and download the *.deb
http://openwebmail.org/openwebmail/download/debian/
OR

INSTALL REQUIRED MODULES FOR OPENWEBMAIL

wget http://launchpadlibrarian.net/67801960/perl-suid_5.10.1-17ubuntu4_amd64.deb
wget http://openwebmail.org/openwebmail/download/debian/2012.02.19/libmd5-perl_0fake-1_amd64.deb
wget http://openwebmail.org/openwebmail/download/debian/owm2.53-2.deb
sudo dpkg -i owm2.53-2.deb

sudo dpkg -i perl-suid_5.10.1-17ubuntu4_amd64.deb
sudo apt-get -f install
sudo dpkg --configure -a
sudo apt-get -y check

sudo a2enmod ssl ; a2ensite default-ssl; /etc/init.d/apache2 restart
sudo a2enmod ssl ; sudo a2ensite default-ssl; /etc/init.d/apache2 restart
sudo a2enmod ssl ; sudo a2ensite default-ssl; sudo /etc/init.d/apache2 restart

sudo dpkg --install owm2.53-2.deb
sudo dpkg -i owm2.53-2.deb libmd5-perl_0fake-1_amd64.deb
sudo dpkg -i perl-suid.deb
sudo apt-get install perl-suid

INSTALL OPENWEBMAIL

cd /var/www
wget  http://openwebmail.org/openwebmail/download/current/openwebmail-current.tar.gz
tar -zxvBpf openwebmail-current.tar.gz
mv data/openwebmail html/
vim /var/www/cgi-bin/openwebmail/etc/openwebmail.conf

mv cgi-bin/ /var/www/
sudo mv cgi-bin/ /var/www/
ll /var/www/
sudo mv html /var/www/

Ubuntu setup

1.Apache 2
2.MySql 5
3.PHP 5
4.Openwebmail
5.MRTG
6.nTop
7.Vnstat
8.webmin
先切換到root以便工作
輸入完密碼後會切換到root 

sysadmin@mail:/$ sudo -s 
root@mai:#

編輯apt的sources.list
root@mail:/# vi /etc/apt/sources.list

將全部的http://tw.archive.ubuntu.com/ubuntu 替換成
http://ftp.twaren.net/ubuntu
最後一行加上
deb ftp://debian.tnc.edu.tw/pub1 b2d
Vi指令
:1,$s/http://tw.archive.ubuntu.com/ubuntu/http://ftp.twaren.net/ubuntu/gic
:wq
先升級套件與安全性更新

apt-get update

然後安裝gdm桌面管理程式,需耗時幾十分鐘左右

安裝gdm桌面管理程式

apt-get install gdm
安裝完成後,先重新啟動電腦
看到登入畫面,按[Ctrl]+[Alt]+[F1]切換到文字模式
一樣先切換到root,以便後續操作

安裝 LAMP Server 一次完成
 
apt-get install apache2 php5 mysql-server phpmyadmin
然後安裝擴充元件

安裝 擴充元件
 
apt-get install apache2-mpm-prefork libapache2-mod-php5 php5-gd php5-imagick php5-mysql
接下來安裝webmin

安裝 webmin
 
apt-get install webmin
安裝完成後可以打開瀏覽器輸入"https://localhost:10000
*預設無法使用root登入
手動安裝方式,先到http://www.webmin.com/download.html
找到 Debian package suitable for Debian, Ubuntu or other derived Linux
http://prdownloads.sourceforge.net/webadmin/webmin_1.480_all.deb 14M

手動安裝 webmin

 cd /tmp
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.480_all.deb
dpkg -i webmin_1.480_all.deb
 

安裝Openwebmail

安裝 openwebmail 相依套件 
apt-get install libconvert-asn1-perl libnet-ldap-perl perl-base libpg-perl perl-suid wwwconfig-common



拼字檢查
apt-get install ispell   
垃圾郵件過濾 
apt-get install spamassassin


安裝 openwebmail 主程式
apt-get install openwebmail
有一個套件無法用apt-get安裝,mindterm

重新啟動apache2 
/etc/init.d/apache2 restart


下載openwebmail主程式
cd /var/www
wget 
http://openwebmail.org/openwebmail/download/current/openwebmail-current.tar.gz

tar -zxvBpf openwebmail-current.tar.gz
 

解壓縮
mv data/openwebmail html/
 

搬移data 子目錄下的 openwebmail 子目錄搬到 html/ 下 rmdir data
 

刪除data
vi /var/www/cgi-bin/openwebmail/etc/openwebmail.conf
------------------------------------------------------------------------------
domainnames auto
 

將 auto 修改成自己的郵件主機
default_iconset default → default_iconset Cool3D.Chinese.Traditional
 

預設中文按鈕
enable_sshterm no
 

禁止使用 openwebmail 以ssh登入主機
mailspooldir            /var/spool/mail
ow_cgidir               /var/www/cgi-bin/openwebmail
ow_cgiurl               /cgi-bin/openwebmail
ow_htmldir              /var/www/openwebmail
ow_htmlurl              /openwebmail
logfile                 /var/log/openwebmail.log

 

修改路徑
enable_viruscheck       no
enable_spamcheck        no
enable_learnspam        no
enable_sshterm          no

:x





 複製defaults底下的dbm.conf 到etc/ 

cd /var/www/cgi-bin/openwebmail/etc/
cp defaults/dbm.conf .



編輯dbm.conf,wq儲存檔案
vi dbm.conf
dbm_ext    .db
dbmopen_ext  .db
dbmopen_haslock    no
 

cd /var/www/cgi-bin/openwebmail/etc/
cp defaults/auth_unix.conf .
vi auth_unix.conf
passwdfile_encrypted     /etc/master.passwd
==>                                /etc/shadow
passwdmkdb      /usr/sbin/pwd_mkdb
==>                     none
check_shell     no     ==>     yes
 


編輯 auth_unix.conf
/var/www/cgi-bin/openwebmail/openwebmail-tool.pl –init
 

重新編譯與啟動openwebmail
cd /var/www/html/openwebmail  


rm -f index.html
mv redirect.html index.html
 

縮短開啟的路徑
如果升級 OpenWebMail 至 2.53-B2D 無法登入,解決方法如下
http://b2d.tnc.edu.tw/phpBB2/viewtopic.php?t=2729
開啟瀏覽器,輸入http://IP/openwebmail就可以開啟openwebmail

安裝Clamav

安裝 clamav元件 

apt-get install clamav

升級clamav
apt-get upgrade clamav 

安裝MRTG

安裝 mrtg元件 

apt-get install mrtg


安裝snmpd
apt-get install snmpd
編輯snmpd

vi /etc/snmp/snmpd.conf 
-------------------------------------------------------
#com2sec paranoid  default         public
com2sec readonly  default         public
#com2sec readwrite default         private

-------------------------------------------------------
找到以上的文字修改為上圖所示
重新啟動snmpd

/etc/init.d/snmpd restart
產生MRTG的設定檔案(解決mrtg監控100M以上流量不準確的問題)

cfgmaker --global 'WorkDir: /var/www/mrtg/' --global 'Options[_]: bits,growright' --output /etc/mrtg.cfg --snmp-option=:::::2 --ifdesc=alias --no-down public@192.168.1.1

對這條命令的簡單說明

a)cfgmaker --snmp-option=:::::2表示監聽時使用snmp2(採用64bit),可支援155M以上的大流量,而預設是snmp1(採用32bit),流量超過100M後就不準確
b)--no-down 表示不管網卡端口是up還是down,都顯示出來,預設只顯示up的端口
c)  --ifdesc=alias 表示將網卡端口描述description作為圖片提示語。預設是--ifdesc=nr 表示interface description uses Interface Number
d)192.168.1.1為要監控的IP位置
讓MRTG運作,連續運行三次如下命令

env LANG=C /usr/bin/mrtg /etc/mrtg.cfg

執行後會顯示錯誤,連續執行三次,在第四次後就不會出現錯誤。
產生mrtg起始頁


 usr/bin/indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg
每五分鐘擷取一次
用crontab -e;編輯crontab內容。加入
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
再用crontab -l;加以驗證是否成功
瀏覽器打開,http://192.168.1.1/mrtg/ 檢查看看有沒有網頁出現
若要繼續將CPU負載監控與WWW連線監控加入,請參閱此連結

安裝nTop

安裝 ntop
apt-get install ntop
 

設定admin的密碼 
ntop --set-admin-password



啟動ntop
/etc/init.d/ntop  start
打開瀏覽器,在地址欄輸入 http://ip:3000  (ip是安裝了ntop的主機IP),就可以用了

停止ntop:
/etc/init.d/ntop  stop


ntop 若是架設在hub底下時便能監視到網路上所有的封包,但若是架設在switch環境下時,除非是開放SPAN的功能,否則只能檢測自己的封包。
由於ntop需要監聽埠,所以最好用iptables限定某些ip可以瀏覽,否則可能帶來安全性問題。

安裝Vnstat

Ubuntu已經內建可直接安裝
安裝 vnstat
apt-get install vnstat
 

設定權限 
chmod o+x /usr/bin/vnstat
chmod o+wx /var/lib/vnstat/ 


啟動vnstat
vnstat -u -i eth0

eth0為網卡的代號,eth0為第一張網卡

vnstat的指令
vnstat : 只有啟動
vnstat -h = 24hr 的流量統計
vnstat -d = 一個月每天的流量統計
vnstat -m = 一年每月的流量統計
vnstat -t = Top 10 的流量統計
vnstat -w = 過去七天與上週跟本週的流量總計
vnstat -tr = 檢視流量

讓流量使用網頁顯示
下載網頁程式  

wget  http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz







解壓縮檔案

tar -xvf vnstat_php_frontend-1.4.1.tar.gz




將解壓縮完的檔案移到www底下的vnstat 

mv vnstat_php_frontend-1.4.1 /var/www/vnstat 
切換到vnstat資料夾底下 

cd /var/www/vnstat

編輯設定
vi config.php

(1)$iface_list = array('eth0'); <---------改成你的網卡代號
(2)$vnstat_bin = '/usr/bin/vnstat';<---------資料庫所在目錄
(3)$data_dir = '/var/db/vnstat';<---------資料庫所在目錄

修改完成之後就可以開啟網頁輸入http://127.0.0.1/vnstat/觀看流量了