CentOS 6系 に Snort インストール

CentOS 6系 に Snortをインストールします。


OSのバージョンチェック。

$ cat /etc/redhat-release
CentOS Linux release 6.0 (Final)

では。早速インストール(^^)
Snortwgetでダウンロードします!

$ wget --no-check-certificate https://www.snort.org/downloads/1862
$ wget --no-check-certificate https://www.snort.org/downloads/1850

「www.snort.org に安全の確認をしないで接続するには、`--no-check-certificate' を使ってください。」
と表示されたので、 --no-check-certificate を付けてダウンロード。
次に解凍を行う。

$ tar xvzf snort-2.9.3.1.tar.gz\?AWSAccessKeyId=AKIAJJSHU7YNPLE5MKOQ\&Expires=1353558882\&Signature=NVvIoesMO%2Fiefo8HetDTkexoKks=
$ tar xvzf daq-1.1.1.tar.gz\?AWSAccessKeyId=AKIAJJSHU7YNPLE5MKOQ\&Expires=1353558923\&Signature=krOgkaxa6qcTr19IFq%2FbjtQPq04=

まずは daq-1.1.1 からインストール行います。

$ cd daq-1.1.1
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk

...(省略)

checking for pcap.h... (cached) no
checking for pcap_lib_version... checking for pcap_lib_version in -lpcap... (cached) no

    ERROR!  Libpcap library version >= 1.0.0 not found.
    Get it from http://www.tcpdump.org

library の libpcap がないらしい。
Libpcap をインストールする。

$ wget http://www.tcpdump.org/release/libpcap-1.2.1.tar.gz
$ tar xvzf libpcap-1.2.1.tar.gz
$ cd libpcap-1.2.1/
$ ./configure
$ make
$ sudo make install

インストールされたか確認。

$ ls -l /usr/local/lib/libpcap.*
-rw-r--r-- 1 root root 1030586 11月 22 13:43 2012 /usr/local/lib/libpcap.a
lrwxrwxrwx 1 root root      12 11月 22 13:43 2012 /usr/local/lib/libpcap.so -> libpcap.so.1
lrwxrwxrwx 1 root root      16 11月 22 13:43 2012 /usr/local/lib/libpcap.so.1 -> libpcap.so.1.2.1
-rwxr-xr-x 1 root root  617214 11月 22 13:43 2012 /usr/local/lib/libpcap.so.1.2.1

libpcap はインストールされたみたいですね。
では、daq-1.1.1 の続きから。

$ cd daq-1.1.1
$ ./configure
$ make 
$ sudo make install

dapもインストールされたか確認。

$ls  /usr/local/lib/daq/
daq_afpacket.la  daq_afpacket.so  daq_dump.la  daq_dump.so  daq_ipfw.la  daq_ipfw.so  daq_pcap.la  daq_pcap.so

おk!
じゃいよいよSnortをインストールします。

$ cd snort-2.9.3.1/
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk

...(省略)

checking for pcap_lib_version... yes
./configure: line 14614: pcre-config: command not found
./configure: line 14620: pcre-config: command not found
checking pcre.h usability... no
checking pcre.h presence... no
checking for pcre.h... no

   ERROR!  Libpcre header not found.
   Get it from http://www.pcre.org

Libpcre の header ファイルがないみたいですね。
Libpcre をインストールしましょう。

$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz 
$ tar xvzf pcre-8.31.tar.gz
$ cd  pcre-8.31/
$ ./configure
$ make
$ sudo make install 

header が入ったかを確認。

$ ls /usr/local/include/pcre.h
/usr/local/include/pcre.h

ちゃんと入ったみたい!
じゃ続きを(´ε`)

$ cd snort-2.9.3.1/
$ ./configure
...(省略)
checking dumbnet.h presence... no
checking for dumbnet.h... no

   ERROR!  dnet header not found, go get it from
   http://code.google.com/p/libdnet/ or use the --with-dnet-*
   options, if you have it installed in an unusual place 

今度は dnet の header がないらしい。
libdnet のインストールを行う。

$ wget http://libdnet.googlecode.com/files/libdnet-1.12.tgz
$ tar xvzf libdnet-1.12.tgz
$ cd libdnet-1.12/
$ ./configure
$ make
$ sudo make install

$ ls /usr/local/include/dnet.h
/usr/local/include/dnet.h

ちゃんと入ったみたいです。
今度こそ!!

$ cd snort-2.9.3.1/
$ ./configure
$ make
$ sudo make install

$ $ /usr/local/bin/snort
Running in packet dump mode

        --== Initializing Snort ==--
Initializing Output Plugins!
ERROR: Failed to lookup interface: no suitable device found. Please specify one with -i switch
Fatal Error, Quitting..

Snortインストールできた(∩´∀`)∩ワーイ




【追記】(その他のエラー)

1.エラー

$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/yoshiaki/final/daq-1.1.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

1.対処法

$ sudo yum install gcc


2.エラー

$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p

...(省略)
checking for getaddrinfo... yes
checking for flex... no
checking for bison... no
checking for capable lex... insufficient
configure: error: Your operating system's lex is insufficient to compile
         libsfbpf. You should install both bison and flex.
         flex is a lex replacement that has many advantages,
         including being able to compile libsfbpf.  For more
         information, see http://www.gnu.org/software/flex/flex.html .

2.対処法

flex と bison を入れる必要がある。
どちらか一つインストールしてある場合は以下のようなエラーが出る。

configure: WARNING: don't have both flex and bison; reverting to lex/yacc

flexwget で取れない。
Webでダウンロードして、送ってインストール。

$ scp flex-2.5.37.tar.gz root@[宛先]:
$ tar xvzf flex-2.5.37.tar.gz
$ cd flex-2.5.37/
$ ./configure
$ make
$ sudo make install

$ wget http://ftp.gnu.org/pub/gnu/bison/bison-2.6.tar.gz 
$ tar xvzf bison-2.6.tar.gz
$ cd bison-2.6/  
$ ./configure
$ make
$ sudo make install


3.エラー

$ make
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
make  all-am
make[1]: ディレクトリ `/home/yoshiaki/final/pcre-8.31' に入ります
  CC     pcre_byte_order.lo
  CC     pcre_compile.lo
  CC     pcre_config.lo
  CC     pcre_dfa_exec.lo
  CC     pcre_exec.lo
  CC     pcre_fullinfo.lo
  CC     pcre_get.lo
  CC     pcre_globals.lo
  CC     pcre_jit_compile.lo
  CC     pcre_maketables.lo
  CC     pcre_newline.lo
  CC     pcre_ord2utf8.lo
  CC     pcre_refcount.lo
  CC     pcre_string_utils.lo
  CC     pcre_study.lo
  CC     pcre_tables.lo
  CC     pcre_ucd.lo
  CC     pcre_valid_utf8.lo
  CC     pcre_version.lo
  CC     pcre_xclass.lo
  CC     pcre_chartables.lo
  CCLD   libpcre.la
  CC     pcreposix.lo
  CCLD   libpcreposix.la
  CXX    pcrecpp.lo
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] エラー 1
make[1]: ディレクトリ `/home/yoshiaki/final/pcre-8.31' から出ます
make: *** [all] エラー 2

3.対処法

C++コンパイラが入ってない。
yum でインストールします。

$ sudo yum install gcc-c++ 
$ sudo yum install libtool