PIXNET Logo登入

頭昏腦脹的小小MIS記錄資料

跳到主文

記錄工作上常會遇到的特殊問題

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 6月 06 週三 201217:21
  • FreeBSD Update Software and Apply Security Patches

最近裝了不少的FreeBSD的各種版本,有發現到一個方便更新ports的工具先記錄下來,不想每一次都來找了
資料來源: http://www.cyberciti.biz/tips/howto-keep-freebsd-system-upto-date.html
 
Updating FreeBSD server system is quite easy. You can apply security patch to keep freebsd system up to date.
Required tools aka software
You need to have following tools on system
(a) portmanager - FreeBSD ultimate ports update utility.
(b) portsnap - It is a system for securely distributing the FreeBSD ports tree. Approximately once an hour, a snapshot of the ports tree is generated, repackaged, and cryptographically signed. The resulting files are then distributed via HTTP.
(c) pkg_version - List the installed version of the package is older than the current version.
FreeBSD install portsnap (for older system version <6.0)
On FreeBSD 6.0+, portsnap is contained in the FreeBSD base (core) system. You only need to to install portsanp as follows for older FreeBSD system:
# cd /usr/ports/ports-mgmt/portsnap
# make install clean
FreeBSD install portmanager
# cd /usr/ports/ports-mgmt/portmanager
# make install clean
Upgrade FreeBSD ports collection
Run portsnap as follows:
# portsnap fetch extract
OR
# portsnap fetch
# portsnap extract
Update FreeBSD packages / software
Now run portmanager to upgrade installed ports:
# portmanager -u
It will updates ports in the correct order based on their dependencies. If a port fails to "make" during update it is marked as ignored. Portmanager will continue updating any ports not marked as "ignored" so long as they are not dependent on the ignored port. Also note that it may take some time if you have large number of application installed.
If you need to upgrade all installed ports with logging, enter:
# portmanager -u -l
How do I upgrade a single software only?
portmanager allows you to update a single port and all of its dependencies. For example update port called bash i.e. bash shell (shells/bash), enter:
# portmanager shells/bash -l -u -f
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(22)

  • 個人分類:FreeBsd5.4
▲top
  • 5月 06 週五 201113:15
  • FreeBSD 使用 GEOM 設定 Software raid1 步驟

FreeBSD 使用 GEOM 設定 Software raid1 步驟
  原本想要使用預設的hardware raid但是有的老舊設備不支援,所以改用內建的Software raid,以下為安裝步驟怕哪天又會用到所以先計一下。
安裝步驟說明:
  先使用一般的方式將FreeBSD先裝起來後,將其他的HD插入重開機就可以找到新的HD了,如果不想這樣用請參考前一篇的新增SCSI HD 的方式做也可以,請自行注意因為版本上的差異指令會不一樣請自己看一下man 就知道了。
  # sysctl kern.geom.debugflags=16     # 開啟後就不會有錯誤訊息
  kern.geom.debugflags: 0 -> 16
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(292)

  • 個人分類:FreeBsd5.4
▲top
  • 1月 31 週一 201114:09
  • Freebsd new add SCSI HD

#camcontrol all
#disklabel -r -w da1s1 auto
# disklabel -e da1s1
# /dev/da1s1c:
type: SCSI
disk: IBM
label:
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 1114
sectors/unit: 17912412
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
c: 17912412 0 unused 0 0 # (Cyl. 0 - 1114*)
~
# newfs /dev/da1s1c
Warning: Block size and bytes per inode restrict cylinders per group to 89.
Warning: 3492 sector(s) in last cylinder unallocated
/dev/da1s1c: 17912412 sectors in 4374 cylinders of 1 tracks, 4096 sectors
8746.3MB in 50 cyl groups (89 c/g, 178.00MB/g, 22144 i/g)
super-block backups (for fsck -b #) at:
32, 364576, 729120, 1093664, 1458208, 1822752, 2187296, 2551840, 2916384,
3280928, 3645472, 4010016, 4374560, 4739104, 5103648, 5468192, 5832736,
6197280, 6561824, 6926368, 7290912, 7655456, 8020000, 8384544, 8749088,
9113632, 9478176, 9842720, 10207264, 10571808, 10936352, 11300896, 11665440,
12029984, 12394528, 12759072, 13123616, 13488160, 13852704, 14217248,
14581792, 14946336, 15310880, 15675424, 16039968, 16404512, 16769056,
17133600, 17498144, 17862688
#mount /dev/da1s1c /data1
#df -h
可參考freebsd handbook作法:
http://www.freebsd.org/doc/zh_TW/books/handbook/disks-adding.html
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(28)

  • 個人分類:FreeBsd5.4
▲top
  • 2月 18 週一 200822:27
  • Putty 中文顯示或輸入的相關設定資料

我慣用TCSH的方式登入,可以修改家目錄下的.cshrc 檔案新增下列資料
vi 輸入或顯示中文
alias vi 'env LC_CTYPE=en_US.ISO8859-1 vi'
cat , more 顯示中文
setenv ENABLE_STARTUP_LOCALE zh_TW.Big5
setenv LC_CTYPE en_US.ISO8859-1
setenv LANG zh_TW.Big5
如何讓FreeBSD像RedHat那樣按tab列出相關的文件資料
set autolist
如何讓FreeBSD像RedHat那樣在ls時顯示多種顏色的目錄
setenv LSCOLORS ExGxFxdxCxegedabagExEx
setenv CLICOLOR yes
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(298)

  • 個人分類:FreeBsd5.4
▲top
  • 9月 25 週一 200613:39
  • 時間校正

因為的我系統一天到晚時間都會跑掉
所以設定其他的方式以避免此問題
ee /etc/crontab
# 時間校正
*       *       */1     *       *       root    ntpdate pool.ntp.org
設定每天執行一次時間校正
因為我時間跑掉的速度太快所以要每天檢查一次
要不應該是15天到1個月再檢查一次即可
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(35)

  • 個人分類:FreeBsd5.4
▲top
  • 6月 21 週三 200610:49
  • 進入single-user mode

今天我的機器突然間開機之後出現Enter full pathname of shell of RETURN for /bin/sh:的錯誤訊息
重開無效,使用GOOGLE大神協助處理找到以下的方式處理
我做到重開SWAP後重開機就好了,因為我的程式等相關資料通通沒有備份
實在是嚇了我好大一跳ㄚ,現在趕緊備份資料準備重灌吧順便換新的版本試試看。
 
內文引用:南市資教
進入single-user mode有兩個方式:
以 root身份在console登入主機,接著執行# shutdown now
重新開機,載入loader時,請在10秒內按一下空白鍵,在OK提示符號下,輸入boot -s接著螢幕會出現
Enter full pathname of shell of RETURN for /bin/sh:
(直接按 enter即可以 B shell進入單人模式)
必要時執行以下動作-
# fsck -p    檢查並修正檔案系統(preen filesystem)
# mount -u /    重新載入 / ,-u 代表改變為可讀可寫狀態
# mount -a -t ufs  載入所有 /etc/fstab有記錄、型態為 ufs的檔案系統
# swapon -a   開啟swap
# adjkerntz -i 讀取CMOS clock為當地時間,如果存在/etc/wall_cmos_clock,就參考時區設定,調整 kernel clock為UTC(格林威治時間)
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(215)

  • 個人分類:FreeBsd5.4
▲top
  • 1月 17 週二 200610:21
  • 如何讓FreeBSD像RedHat那樣在ls時顯示多種顏色的目錄

如何讓FreeBSD像RedHat那樣在ls時顯示多種顏色的目錄
setenv LSCOLORS ExGxFxdxCxegedabagExEx
setenv CLICOLOR yes
 
然後,執行:
代碼:
sed -i.bak -E s/set\ prompt/#set\ prompt/g /root/.cshrc
 
如何讓FreeBSD像RedHat那樣按tab列出相關的文件資料
set autolist
 
 
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(134)

  • 個人分類:FreeBsd5.4
▲top
  • 8月 06 週六 200516:36
  • Ipfilter+Bridge (附加ipant的部份)

有牽涉到ipnat的我有在前面加#但是我並沒有實際安裝過僅供參考
但是Ipfilter+Bridge 我測過是OK的
Setp 1.
重新編輯新的Kernel 同時加入bridge 的option
cd /usr/src/sys/i386/conf/
cp /usr/src/sys/i386/conf/GENERIC /etc/NEWIPF
ln -s /etc/NEWIPF
ee NEWIPF
ident NEWIPF      #  ident記得要改成新的NEWIPF
options BRIDGE   #  加入這行即可
##### LOG檔配置 #####
options IPFILTER
options IPFILTER_LOG
options IPFILTER_DEFAULT_BLOCK
cd /usr/src/sys/i386/compile/NEWIPF
make depend all install
 
Setp 2.
ee /etc/sysctl.conf
net.inet.ip.forwarding=1
net.link.ether.bridge.enable=1
net.link.ether.bridge.ipf=1
net.link.ether.bridge.config=lnc0,lnc1
 
ee /etc/rc.conf
ipfilter_enable="YES"             ##啟動IPF
ipfilter_rules="/etc/ipf.rules"    ##設定規則
ipmon_enable="YES"             ##啟動記錄器
ipmon_flags="-D /var/log/ipfilter.log" # D=服務啟動  s=使用記錄
                                   # v=紀錄TCP窗口大小ACK和順序號 n=將IP和端口設定為名稱
#ipnat_enable="YES"                 ##啟動IPNAT
#ipnat_rules="/etc/ipnat.rules "    ##設定規則
vi /var/log/ipfilter.log
chmod 755 /var/log/ipfilter.log
 
網卡ip只要設一塊就可以了
並再起頭設定網卡的地方加入另一張網卡的設定
ifconfig_lnc1="inet 10.10.10.254 netmask 255.255.255.0"
 
Setp 3.
設訂規則
ee /etc/ipf.rules
pass in all
pass out all
 
#ee /etc/ipnat.rules
 
 
指令說明:
#kldstat  ( 看ipfilter有無被驅動 )
#ipf -V  ( -V查看ipfilter的版本 )
#ipf -D  ( 停止 ipfilter )
#ipf -E  ( 啟動 ipfilter )
#ipf -Fa -f /etc/ipf.rules  ( -Fa清除所有rule,-f 導入新的rule,為更新ipf.rules後重新啟動必下指令)
#ipfstats  ( 統計所有封包狀態 )
#ipfstats -o  ( -o看所有output的rule )
#ipfstats -i  ( -i看所以input的rule )
#ipmon  ( 觀查所有ip及封包走向 IP -> host, PORT -> protocol )
#ipnat -C  ( 清除所有規則 )
#ipnat -l  ( 查看目前設置的轉換規則及已經執行過後的轉換關係 )
#ipnat -s  ( 查看ipnat的狀態 )
#ipnat -f /etc/ipnat.rules  ( 重讀 ipnat.rules )

 
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(53)

  • 個人分類:FreeBsd5.4
▲top
  • 8月 02 週二 200514:40
  • EXIM+cucipop+Openwebmail+Clamav+amavisd-new+SpamAssassin

1.安裝EXIM
cd /usr/ports/mail/exim
make install clean
設定要收信的DOMAIN資料
ee /usr/local/etc/exim/configure
primary_hostname = 主機名稱(要以FQND為主)
domainlist local_domains = @ : test.com.tw   (要收信的DOMAIN)
domainlist relay_to_domains = test.com.tw (要收信的DOMAIN)
hostlist   relay_from_hosts = localhost : 127.0.0.1  (LOCAL IP)
若要增加SMTP驗證發信請在最下面加入
##### SMTP驗證 #####
login:
   driver = plaintext
   public_name = LOGIN
   server_prompts = "Username:: : Password::"
   server_condition = "${if crypteq{$2}{${extract{1}{:}{${lookup{$1}lsearch{/usr/local/etc/exim/exim.passwd}{$value}{*:*}}}}}{1}{0}}"
   server_set_id = $1
 

ee /usr/local/etc/rc.d/eximpasswd.sh  --新增此檔
#!/bin/sh
awk -F: '
/^(sash)?root:/ { next }
/^[^:]*:.[^:]/ { print $1 ":" $2 }
' /etc/master.passwd > /usr/local/etc/exim/auth.passwd.tmp
mv /usr/local/etc/exim/auth.passwd.tmp /usr/local/etc/exim/passwd
 
設定權限
chmod 755 /usr/local/etc/rc.d/eximpasswd.sh
設定每10分鐘COPY一次密碼
ee /etc/crontab
*/10 *       *       *       *       root    /usr/local/etc/rc.d/eximpasswd.sh
設定開機啟動
ee /etc/rc.conf
sendmail_enable="NONE"
exim_enable="YES"
 
2.安裝POP3(cucipop)
cd /usr/ports/mail/cucipop/
make install clean
執行檔是: /usr/local/libexec/cucipop
開機自動執行:
  a.檔案: ee /usr/local/etc/rc.d/cucipop.sh (自己新增檔案)
     內容如下:
     /usr/local/libexec/cucipop -YaSE 2M  (此參數表示超過兩個月的信砍之)
  b.變更權限:
    chmod 700 /usr/local/etc/rc.d/cucipop.sh
  c.手動啟動
    /usr/local/etc/rc.d/cucipop.sh
 
3.安裝openwebmail
因為SUIDPERL的安全性問題所以要移除重裝
cd /usr/ports/lang/perl5.8/   
make deinstall clean  
make -DENABLE_SUIDPERL install clean
cd /usr/ports/mail/openwebmail
make all install clean
設定檔在 ee /usr/local/www/cgi-bin/openwebmail/etc/openwebmail.conf
enable_sshterm          no -關閉ssh的方式
 
4.安裝Clamav
cd /usr/ports/security/clamav
make install clean
在 ee /etc/crontab 檔案中在root欄位中加入:
0 6,18 * * * clamav /usr/local/bin/freshclam --quiet -l /var/log/clam-update.log
即每天上午 6 點和下午 6 點各更新一次病毒碼資料庫
mkdir /var/run/clamav/clamd
ee /usr/local/etc/clamd.conf
# Path to a local socket file the daemon will listen on.
# Default: disabled
#LocalSocket /var/run/clamav/clamd
LocalSocket /tmp/clamd
DatabaseDirectory /usr/local/share/clamav  要變成
DatabaseDirectory /var/db/clamav
User clamav 變更成
User vscan
 
5.安裝amavisd-new
cd /usr/ports/security/amavisd-new
make install clean
設定amavisd-new的設定檔
ee /usr/local/etc/amavisd.conf
$mydomain = 'my-domain.ru';   ---修正DOMAIN
$forward_method = 'smtp:127.0.0.1:10025';  移除前方的#
$notify_method = $forward_method;     增加一個
$inet_socket_port = 10024;    --確定資料
@av_scanners = (  --這是選擇您的掃毒程式將不要的MARK掉要的開起來
 ### http://www.clamav.net/
 ['ClamAV-clamd',
#   \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd"],  --將此行變更成下面的
    \&ask_daemon, ["CONTSCAN {}\n", "/tmp/clamd"],
exim設定
ee /usr/local/etc/exim/configure
於hostlist   relay_from_hosts =之下加入
local_interfaces = 0.0.0.0.25 : 127.0.0.1.10025
於[routers]處加入
amavis:
        driver = manualroute
        condition = "${if eq {$interface_port}{10025} {0}{1}}"
        # if scanning incoming mails, uncomment the following line and
        # change local_domains accordingly
        # domains = +local_domains
        transport = amavis
        route_list = "* localhost byname"
        self = send
       
於[transports]處加入
amavis:
       driver = smtp
       port = 10024
       allow_localhost
6.安裝SpamAssassin
cd /usr/ports/mail/spamd/
make install clean
cp /usr/local/etc/spamd.conf.sample /usr/local/etc/spamd.conf
ee /usr/local/etc/spamd.conf
# Enable the Bayes system. 使用貝氏學習系統
use_bayes               1
# Enable Bayes auto-learning.  開起貝氏自動學習功能
auto_learn              1
# Enable or Disable network checks.  略過 RBLs 之檢查
skip_rbl_checks         0
# Blacklist.  黑色清單,判定減 + 100 分
#blacklist_from *@sohu.com *@mailfb.com
# Whitelist . 白色清單,判定加 -100 分
#whitelist_from *@yahoo.com.tw *@yahoo.com.hk *@yahoogroups.com.hk
#whitelist_from rika@rika.idv.tw
rc.conf 設定 --此處要注意優先順序
ee /etc/rc.conf
spamd_enable="YES"
amavisd_enable="YES"
clamav_clamd_enable="YES"
clamav_freshclam_enable="YES"
exim_enable="YES"
 
細部調整說明
AMaViSd-new
#$QUARANTINEDIR = '/var/virusmails';  --信件預設會保留在該資料夾若不想保留請註解掉即可
AMaViSd-new 會呼叫 Mail::SpamAssassin 計算 Hit,分數越高的越可能是廣告信。
$sa_auto_whitelist = 1;    # 啟用自動學習白名單 White List
$sa_mail_body_size_limit = 200*1024;     # 超過某個特定大小的郵件就不經過 SpamAssassin 的掃瞄。
$sa_tag_level_deflt  = 2.0;     # 超過這個分數標準者,視為垃圾郵件打分數。
$sa_tag2_level_deflt = 6.3;     # 超過這個分數標準者,才允許在郵件標頭加入 Spam 資訊。
$sa_kill_level_deflt = 30 ;   # 超過這個標準者,就直接將信件備份後刪除。
 
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(144)

  • 個人分類:FreeBsd5.4
▲top
  • 7月 15 週五 200516:17
  • 流量監控

A.trafshow --loading較輕
cd /usr/ports/net/trafshow
make install clean
rehash  不行就reboot
指令為
trafshow -i 網卡名稱(lnc0)
         -ni 網卡名稱(lnc0)
B.ntop --loading較重
cd  /usr/ports/net/ntop/
make install clean
rehash
ntop -A --設定管理者的密碼,預設帳號是admin
ee /usr/local/etc/rc.d/ntop.sh        //修改ntop.sh內容如下
###Network interface(s) to be monitored;
###may be blank, or comma-separated list
interfaces=' '           //預設值
interfaces='vr0'         //更改後(改成您想要監聽的網路介面)
###[IP:]port for serving HTTP; set to '0' to disable
http_port='3000'         //預設值(http聽的port)
http_port='5678'         //更改後(改成您想要聽的http port)
###[IP:]port for serving HTTPS; set to '0' to disable
###The certificate is /usr/local/etc/ntop/ntop-cert.pem
https_port='3001'        //預設值(https聽的port)
https_port='8765'        //更改後(改成您想要監聽的https port)
cd /usr/local/etc/rc.d              //切換路徑
chmod 755 ntop.sh                   //讓ntop能開機自行啟動
/usr/local/etc/rc.d/ntop.sh start   //啟動ntop(成功訊息如下)
(繼續閱讀...)
文章標籤

brucebin 發表在 痞客邦 留言(0) 人氣(158)

  • 個人分類:FreeBsd5.4
▲top
12»

自訂側欄

自訂側欄

個人資訊

brucebin
暱稱:
brucebin
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (9,556)如何解決 Outlook 2007 / 2010 中的離線狀況
  • (5,463)修改Outlook電子郵件規則時會發生"規則已被停用"的錯誤訊息
  • (3,868)幾種轉換虛擬機器格式的工具
  • (2,863)[轉貼]Fckeditor 漏洞整理
  • (1,532)Esxi install drivers
  • (601)DOS指令集
  • (314)VMware ESXi / Workstation 無法啟動 Windows 2012 RC
  • (298)Putty 中文顯示或輸入的相關設定資料
  • (151)phpmyadmin 使用Big5語系的問題
  • (46)CVSUP 安裝更新

文章分類

  • MAC (1)
  • Hyper-v (1)
  • Centos (2)
  • Ubuntu (1)
  • PLESK (1)
  • 套件問題 (2)
  • php (2)
  • MSSQL (1)
  • office (4)
  • ASP.NET (2)
  • WINDOWS (11)
  • VMware (12)
  • MYSQL (2)
  • FreeBsd5.4 (13)
  • 未分類文章 (1)

最新文章

  • Mac OS X Mountain Lion InstallESD.dmg 轉 ISO
  • Centos 忘記 root 密碼
  • 幾種轉換虛擬機器格式的工具
  • Windows 8 程式取得管理者權限 或 關閉 UAC 方法
  • Windows 8 啟動時發生"DNS不存在"的錯誤
  • Centos 在 VMware Workstation 開機網卡不會啟動
  • Ubuntu 11.10 檢視CPU溫度
  • PHP 讀取/寫入範例
  • Windows 2008 執行 Sysprep 的方式
  • VMware ESXi / Workstation 無法啟動 Windows 2012 RC

最新留言

  • [07/12/25] uk 於文章「session_start在UTF8出現...」留言:
    謝謝賓哥分享 原來最近遇到的都是屬於這種的 .........

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: