顯示具有 CentOS 標籤的文章。 顯示所有文章
顯示具有 CentOS 標籤的文章。 顯示所有文章

2016/05/18

CentOS 安裝 rpcapd

在CentOS上安裝rpcapd順序

1. 下載winpacp source (官方載點)
2. 解開壓縮檔 並參考 https://www.winpcap.org/pipermail/winpcap-users/2011-November/004540.html
    修正daemon.c檔案的錯誤

3. 依據http://www.winpcap.org/docs/docs_40_2/html/group__remote.html 的說明編譯並啟用 

參考來源:
http://www.winpcap.org/docs/docs_40_2/html/group__remote.html
https://www.winpcap.org/pipermail/winpcap-users/2011-November/004540.html

2015/11/28

Linux Expect 語法

參考來源:https://devcentral.f5.com/articles/example-expect-script
參考來源:http://inguza.com/document/expect-and-tcl-mini-reference-manual

先裝好epxect後 就可以用下列語法透過ssh去控制遠端主機或設備
--------------
#!/usr/bin/expect -f
set HOST "目標IP"
set USER "帳號"
set PASS "密碼"
set SERVER [lindex $argv 0]    // 參數一  字串
set TARGET [lindex $argv 1]  // 參數二 以空格分隔得字串
append SERVER "_WHITE_LIST"  // 在參數一後面加字串

spawn ssh -o StrictHostKeyChecking=no $USER@$HOST    // ssh連線到目標主機
expect  "password:" { send "$PASS\r";}   //  密碼
expect  " #" { send "config firewall addrgrp \r"; }  // 指令
expect  "(addrgrp) #" { send "edit $SERVER \r"; }  // 指令
expect  "($SERVER) #" {
        foreach target [split $TARGET " "] {       // foreach 迴圈    變數來源是用以空格分隔得字串
                send "unselect member [lindex $target 0] \r";   // 指令
                continue;  
        };
}
expect  "($SERVER) #" { send "end \r"; }   // 指令
expect  " #"  {  send "config firewall address \r"; }
expect  "(address) #" {
        foreach target [split $TARGET " "] {
                send "delete [lindex $target 0] \r";
                continue;
        };
}
expect  "(address) #" { send "end \r"; }
expect  " #" { send "exit \r"; }   // 登出主機

----------------

2015/10/26

CentOS 7 Bridge跟Traffic Control

Bridge 設定  http://www.ichiayi.com/wiki/tech/linux_bridge
Traffic Control 設定 http://chunchaichang.blogspot.tw/2010/08/qos.html

這裡有一個重點Bridge預設是不會受iptables的控制,找了一下有下列文章
http://stackoverflow.com/questions/653812/why-doesnt-my-iptables-entries-block-pinging-a-xen-virtual-machine
重點就是要把Bridge的nf功能打開http://ebtables.netfilter.org/documentation/bridge-nf.html
nf功能可以在sysctl.conf裡面設定。

開機要自動做好TC的話,請記得把rc.local改成可執行。

2012/02/06

webmin及openwebmail安裝

以下都是透過yum方式安裝,rpm及tarball方式請自行google。
一、安裝webmin
        參考:http://webmin.com/rpm.html

Using the Webmin YUM repository

If you like to install and update Webmin via RPM, create the/etc/yum.repos.d/webmin.repo file containing :[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
You should also fetch and install my GPG key with which the packages are signed, with the commands :wget http://www.webmin.com/jcameron-key.asc
rpm --import jcameron-key.asc
You will now be able to install with the command :yum install webminAll dependencies should be resolved automatically.


二、安裝openwebmail


How to install openwebmail from yum repository
==============================================
Thomas Chung <tchung@openwebmail.org>
2008.05.29
UPDATE 2010.05.24
Install perl-Text-Iconv from rpmforge for your arch if you're running RHEL or CentOS:
http://dag.wieers.com/rpm/packages/perl-Text-Iconv/
$ su -
# cd /etc/yum.repos.d
# lftpget http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo
# yum install openwebmail
fedora 100% |=========================| 2.1 kB 00:00
openwebmail 100% |=========================| 951 B 00:00
updates 100% |=========================| 2.3 kB 00:00
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package openwebmail.i386 0:2.53-1 set to be updated
--> Processing Dependency: openwebmail-data = 2.53-1 for package: openwebmail
--> Processing Dependency: perl-suidperl for package: openwebmail
--> Processing Dependency: perl-Text-Iconv for package: openwebmail
--> Running transaction check
---> Package openwebmail-data.i386 0:2.53-1 set to be updated
---> Package perl-suidperl.i386 4:5.8.8-32.fc8 set to be updated
---> Package perl-Text-Iconv.i386 0:1.5-1.fc8 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing for dependencies:
openwebmail i386 2.53-1 openwebmail 2.3 M
openwebmail-data i386 2.53-1 openwebmail 7.0 M
perl-Text-Iconv i386 1.5-1.fc8 fedora 20 k
perl-suidperl i386 4:5.8.8-32.fc8 updates 60 k
Transaction Summary
=============================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-Text-Iconv-1. 100% |=========================| 20 kB 00:00
(2/4): openwebmail-2.53-1 100% |=========================| 2.3 MB 00:03
(3/4): perl-suidperl-5.8. 100% |=========================| 60 kB 00:00
(4/4): openwebmail-data-2 100% |=========================| 7.0 MB 00:10
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cfb164d8
Importing GPG key 0xCFB164D8 "Thomas Chung <tchung@openwebmail.org>" from http://openwebmail.org/.../RPM-GPG-KEY-openwebmail
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-Text-Iconv ######################### [1/4]
Installing: perl-suidperl ######################### [2/4]
Installing: openwebmail ######################### [3/4]
Permission and Ownership for openwebmail files have been fixed!
Please execute following tool first as a root:
/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init
After restarting httpd service, login with non-root account from
http://localhost.localdomain/cgi-bin/openwebmail/openwebmail.pl
or http://localhost.localdomain/webmail
If SELinux enabled, you may need to set it 'permissive' in
/etc/sysconfig/selinux or system-config-selinux
Installing: openwebmail-data ######################### [4/4]
Dependency Installed: openwebmail.i386 0:2.53-1 openwebmail-data.i386 0:2.53-1 perl-Text-Iconv.i386 0:1.5-1.fc8 perl-suidperl.i386 4:5.8.8-32.fc8
Complete!
三、 openwebmail安裝好後的設定
        修改/var/log/openwebmail.log的 selinux設定
參考:http://j796160836.pixnet.net/blog/post/21882397-%5B%E7%AD%86%E8%A8%98%5D%5B%E6%A5%B5%E9%87%8D%E8%A6%81%5Dopenwebmail%E7%9A%84%E9%97%9C%E9%8D%B5%E8%A8%AD%E5%AE%9A%EF%BC%8C%E8%A8%AD%E5%AE%9Aselinu



2011/08/04

Install snort 2.9.0.5 on CentOS 5.5

今天裝Snort 2.9.0.5到CentOS 5.5上,遭遇很多問題。
所以寫這篇紀錄如何安裝。這篇完全用tarball方式安裝,RPM部份請參考(http://forum.icst.org.tw/phpbb/viewtopic.php?f=11&t=20365)。
這邊是安裝好CentOS 5.5並且將全部套件更新到最新版後的安裝方式。

1.事前準備
  1.1 從snort官網下載snort-2.9.0.5.tar.gz, dag-0.5.tar.gz
  1.2 下載snort的rule,免費的即可,前提是你要先註冊一個帳號。將來有想要升級的話也可以升級上去。
        snortrules-snapshot-2904.tar.gz, snortrules-snapshot-2905.tar.gz
  1.3 到http://www.tcpdump.org 下載libpcap-1.1.1.tar.gz
  1.4 到http://libdnet.sourceforge.net 下載libdnet-1.11.tar.gz
  1.5 將snort,dag,libdnet及libpcap解開(請自行到鳥哥那瞭解如何解壓縮),到各自目錄夾。
        通常解開的目錄就是檔案去掉tar.gz的部份。
        例:snort-2.9.0.5.tar.gz解開後目錄名稱為snort-2.9.0.5。
2.開始安裝
  2.1 用瀏覽器打開 Install_Snort_2.8.6_on_CentOS_5.5.pdf
       請依照裡面的 Snort Installation and Setup章節安裝。裡面會要你用yum安裝很多套件。
       安裝完後會到 Making directories and building/installing Snort: 章節。
       接下來的請依順序安裝,不然會有錯誤訊息。
  2.2 安裝libdnet
cd libdnet-1.11
./configure --prefix=/usr
make
make install

  2.3 安裝libpcap
cd libpcap-1.1.1
./configure --prefix=/usr
make
make install

  2.4 安裝dag
cd dag-0.5
./configure --prefix=/usr
make
make install

  2.5 安裝snort
cd snort-2.9.0.5
./configure --with-mysql --enable-dynamicplugin --enable-ipv6 --enable-gre --enable-mpls --enable-targetbased --enable-decoder-preprocessor-rules --enable-ppm --enable-perfprofiling --enable-zlib --enable-active-response --enable-normalizer --enable-reload --enable-react --enable-flexresp3
make
make install

  2.6 接著就接續Making directories and building/installing Snort:後面章節的部份繼續安裝下去。

3. PHP Pear部份
   3.1 安裝php pear

yum -y install php-pear
pear upgrade --force http://download.pear.php.net/package/PEAR-1.9.1.tgz
pear install Numbers_Roman
pear install channel://pear.php.net/Numbers_Words-0.16.2
pear install Image_Color
pear install channel://pear.php.net/Image_Canvas-0.3.2
pear install channel://pear.php.net/Image_Graph-0.7.2


4. adodb
wget http://sourceforge.net/projects/adodb/files/adodb-php5-only/adodb-511-for-php5/adodb511.tgz/download


5. secureideas
wget http://sourceforge.net/projects/secureideas/files/BASE/base-1.4.5/base-1.4.5.tar.gz/download


6. Barnyard2
安裝裡面的網站已經不存在了,現在換到這個https://nodeload.github.com/firnsy/barnyard2/tarball/master。
  6.1 請參閱doc裡面的INSTALL文件
        如果發生 AM_PATH_LIBPRELUDE 錯誤的話,依下面方式處理。

cp snort-2.9.0.5/m4/libprelude.m4 /usr/share/aclocal

snort-2.9.0.5可以改成你實際解開的目錄。
  6.2 之後就./configure --with-mysql --prefix=/usr沒問題的話就可以安裝了

7. 修改snort.conf
     把ipvar部份全部改成var。

全部做完後就可以開始使用Snort了。

2011/02/22

Nagios Plugin Check_SNMP

OS: CentOS 5.5
Nagios: nagios-3.2.3-3.el5.rf.i386
這篇是關於Nagios Plugin Check_SNMP中關於--rate指令的使用方式。
如果你是用YUM或是apt等方式安裝的Nagios,可能在使用check_snmp的--rate選項的時候會發生錯誤。
原因是因為check_snmp在儲存rate的狀態的時候,會除存在/var/check_snmp裡面,而extinfo.cgi確無法在開啟檔案,原因是目錄建立的時候,使用者及群組不是nagios(或你自訂的群組),權限也只有700。
所以將使用者及群組改成nagios(或你自訂的群組),權限也修改成755(或你覺得安全權限)。
裡面如果原本就有檔案的話,也請將使用者及群組改成nagios(或你自訂的群組),權限640即可。想省事一點可以把檔案全砍了,反正重新建立也不會有啥影響。之後重新啟動nagios就會正常。