2009年11月10日 星期二

Firewall指令

#iptables -t filter -L(列出表的規則內容)
                          -F(清空表格的內容 )
                          -A [鏈名大寫] (新增規則在最後一行)
                          -I [鏈名大寫] [行號] (插入到第幾行,可省預設第一行)
                          -R [鏈名大寫] [行號] (覆寫第幾行,不可省略行號)
                          -D[鏈名大寫] [行號] (刪除第幾行,可省預設符合的行)
                          -P(設定default-rule policy,該行永遠在鏈的所有規則之後)
#iptables --help (可查詢更多用法)
-t : 選表格
filter (內定)
nat
manager
raw


=======================
filter表包含三個chain (鏈)(可視為記憶體緩衝區或檢查區)
INPUT
OUTPUT
FORWARD
=======================
實作1

#iptables -F
#iptables -A INPUT -p tcp ACCEPT (-p:protocol為tcp, 動作為ACCEPT)
#iptables -A INPUT -p icmp -j ACCEPT
#iptables -P INPUT DROP (設定內定規則為丟棄)
[root@h155 ~]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
note:除ACCEPT,DROP外,常用REJECT,表示丟棄packet並回報原發送主機,該packet丟棄
======================================
實作2
#iptables -I FORWARD 2 -o eth0 -d www.facebook.com -p tcp --dport 80 -j REJECT

#iptables -R FORWARD 2 -o eth0 -d ! www.facebook.com -p tcp --dport 80 -j ACCEPT

note:
eth0為連上internet之外介面經本機上internet之封包若是http://www.facebook.com的流量則將拒絶,並發訊息告知. (!表示反向的意思)

2009年11月2日 星期一

CentOS-安裝ncftp Client(source安裝)

Download ncftp
  • #wget ftp://ftp.ncftp.com/ncftp/ncftp-3.2.3-src.tar.gz
解壓縮
  • #tar xvfz ncftp-3.2.3-src.tar.gz
安裝
  • #cd ncftp-3.2.3
  • #vi README.txt --->先讀readme,了解要安裝的指令步驟
    • 2. General Instructions
      -----------------------

      To build NcFTP and the utility programs, you can simply do the following:

          1.  (Optional) Install ncurses (available from a GNU mirror).
          2.  Run the "./configure" script in the NcFTP source directory.
          3.  (Probably not necessary) Inspect the Makefiles in each subdirectory.
          4.  (Probably not necessary) Browse and edit config.h.
          5.  "make"
          6.  "make install"
  • #./configure --->check安裝環境
  • #make --->compiling
  • #make install --->安裝
    • Done installing NcFTP.

測試
  • #ncftp ftpserver --->連線到ftp站台
  • #ncftpput --->上傳檔案
  • #ncftpget --->取得檔案

CentOS-安裝Word Press

安裝word Press
  • #wget http://wordpress.org/latest.tar.gz
  • #mv wordpress /var/www/html
  • #chown apache.apache wordpress/ -R --->更換權限
設定
  • 執行http://IP/wordpress開始設定
  • 在設定過程中,可以在MySQL中建立db給word press使用

CentOS-網路卡的設定檔的放置位置

網路卡的設定檔的放置位置
/etc/sysconfig/network --->網路相關的設定檔案
/etc/sysconfig/network-scripts/*--->網路卡的設定,例如:ifcfg-eth0

GUI軟體更新設定檔時,設定檔放置的位置
/etc/sysconfig/networking/devices --->網路卡的設定
/etc/sysconfig/networking/profiles/* --->網路相關的設定檔案

NTP網路校時協定

NTP:network time protocol
#date --->查看現在的時間
#hwclock -r --->讀硬體時間 (r=read)
#ntpdate watch.stdtime.gov.tw --->校對台灣時間,以watch.stdtime.gov.tw的時間為準
#date --->查看現在的時間
#hwclock -w --->寫入硬體更新的時間 (w=write)

Note:安裝ntpd軟體,可成為時間對時伺服器