2016年7月18日 星期一

centos 6, nfdump and nfsen

修改20161007

版本:
Linux 2.6.32-642.3.1.el6.x86_64

Red Hat 4.4.7-17
nfdump-1.6.13
nfsen-1.3.6p1


更新下載檔案:
yum update

yum install -y httpd php wget gcc make rrdtool-devel rrdtool-perl perl-MailTools perl-Socket6 flex byacc

wget https://sourceforge.net/projects/nfdump/files/stable/nfdump-1.6.13/nfdump-1.6.13.tar.gz/download

wget https://sourceforge.net/projects/nfsen/files/stable/nfsen-1.3.6p1/nfsen-1.3.6p1.tar.gz

tar -zxvf /root/nfdump-1.6.13.tar.gz
tar -zxvf /root/nfsen-1.3.6p1.tar.gz

useradd -G apache -s /bin/false netflow
新增使用者,加入apache群組,無法用shell登入

防火牆設定:
iptables -I INPUT -p tcp  --dport 443 -j ACCEPT
iptables -I INPUT -p tcp  --dport 80 -j ACCEPT
iptables -I INPUT -p udp  --dport 9995 -j ACCEPT
iptables -I INPUT -p udp  --dport 9996 -j ACCEPT
service iptables save
開放http,https還有netflow流量預設port

selinux設定:
vim /etc/selinux/config
set SELINUX=disabled

reboot

nfdump安裝:
/root/nfdump-1.6.13/configure --enable-nfprofile --enable-nftrack --enable-sflow
cp /root/nfsen-1.3.6p1/etc/nfsen-dist.conf /root/nfsen-1.3.6p1/etc/nfsen.conf

cd /root/nfdump-1.6.13
make
make install
nfdump功能

nfsen安裝:
vim /root/nfsen-1.3.6p1/etc/nfsen.conf
$BASEDIR = "/home/netflow";  

$USER    = "netflow";

$WWWUSER  = "apache";
$WWWGROUP = "apache";

%sources = (
    'home'    => { 'port' => '9995', 'col' => '#0000ff', 'type' => 'netflow' },
    'internal'    => { 'port' => '9996', 'col' => '#FF0000', 'type' => 'netflow' },
#    'peer1'        => { 'port' => '9996', 'IP' => '172.16.17.18' },
#    'peer2'        => { 'port' => '9996', 'IP' => '172.16.17.19' },
);

/root/nfsen-1.3.6p1/install.pl /root/nfsen-1.3.6p1/etc/nfsen.conf
/home/netflow/bin/nfsen start

vim /etc/init.d/nfsen
#!/bin/bash
#
# chkconfig: - 50 50
# description: nfsen

DAEMON=/home/netflow/bin/nfsen
case "$1" in
start)
$DAEMON start
;;
stop)
$DAEMON stop
;;
status)
$DAEMON status
;;
restart)
$DAEMON stop
sleep 1
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0

chkconfig --add nfsen
chkconfig nfsen on

網頁設定:
vim /etc/httpd/conf.d/nfsen.conf
Alias /nfsen "/var/www/nfsen"

<Directory "/var/www/nfsen">
DirectoryIndex nfsen.php
Options -Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
service httpd restart

權限設定:
群組apache對${BASEDIR}/var/run/nfsen.conf必須有rw權限
我的${BASEDIR}是/home/netflow
所以home, netflow, var 和 run資料夾apache群組必須要有rx權限

使用windows系統用flowalyzer產生netflow流量
Flowalyzer NetFlow Generator2.0


http://{IP or FQDN}/nfsen/



2016年6月17日 星期五

AD 操作主機(operation master)


操作主機(Operation Master)

  • 專門用來變更資料庫內特殊資料,以避免衝突發生
  • 預設五部操作主機是在第一台DC上
  • 樹系範圍操作主機
    • 架構主機(Schema Master)
    • 網域命名主機(Domain Naming Master)
  • 網域範圍操作主機
    • RID主機(relative identifier operations master )
    • PDC模擬主機(The primary domain controller emulator operations master)
    • 基礎結構主機(Infrastructure Master)

PDC模擬主機(PDC Emulator)

  • 降低使用者變更密碼的時間延遲
  • 提供時間同步對時服務
  • 管理及變更GPO
  • 查詢操作主機:dsquery server  –hasfsmo PDC

PDC模擬主機對時服務

  • 主機設定對時伺服器
  • W32tm /config /update /manualpeerlist:”<對時伺服器>,<輪詢間格>”
  • 主機開始同步
  • W32tm /resync
  • 用戶端對時
  • Net time \\DCComputer /set /y

PDC操作主機失敗

RID主機

  • 負責管理RID
  • 每個使用者、電腦、群組會被分配一個SID,而這SID是由Domain SID和RID組成
  • 藉由RID主機從一個Domain移動物件到其他Domain
  • 查詢操作主機:dsquery server  –hasfsmo RID

RID操作主機失敗


基礎結構主機

  • 基礎結構主機主要用來維護本網域物件參考到其他網域物件時,ID的一致性
  • 查詢操作主機:dsquery server  –hasfsmo INFR

基礎結構主機失敗

架構主機(Schema Master)

  • 架構主機定義儲存在AD資料庫內的物件類別和屬性
  • 更新或新增Schema都必須透過架構主機
  • 查詢操作主機:dsquery server –forest –hasfsmo schema

架構主機失敗


網域命名主機(Domain Naming Master)

  • 負責AD樹系網域的新增和刪除
  • 查詢操作主機:dsquery server –forest –hasfsmo name

網域命名主機失敗

一般變更操作主機

PDC主機


PDC主機


基礎結構主機

架構主機

需先變更目前架構主機,選擇變更AD網域控制站

網域命名主機

強制指定操作主機

  • 操作主機損壞,無法回復
  • 無法使用一般轉移操作主機

  • 使用命令列:
    • Ntdsuit
    • Roles
    • Connections
    • Connect to server <需要被指定的server名稱>  
    • Quit
    • <各操作主機的強制指令>

強制指定實作

各操作主機的強制指令


From: https://technet.microsoft.com/en-us/library/cc816779(v=ws.10).aspx