linux 和 window 上route命令使用
Thursday, October 9, 2008
linux:
route add -net 192.168.81.0 netmask 255.255.255.0 gw 172.168.100.2
window:
route add 192.168.81.0 mask 255.255.255.0 172.168.100.2 -p
freebsd ports 使用http代理
ee /etc/make.conf
添加
FETCH_ENV?=HTTP_PROXY=http://user:password@proxyurl:proxyport
iptables的ipp2p模块加载
Tuesday, October 7, 2008
reference:
http://wiki.centos.org/HowTos/I_need_the_Kernel_Source
http://sourceforge.net/project/showfiles.php?group_id=80085
http://blog.chinaunix.net/u/28814/showart.php?id=1220921
http://linux.chinaunix.net/bbs/thread-1032941-1-1.html
http://linux.chinaunix.net/bbs/viewthread.php?tid=914377
出现error
重启机器后发现dmesg
e1000 device eth0 does not seem to be present, delaying initialization.
处理方式
depmod -a
modprobe e1000
lsmod
service network restart
补充命令:lspci
本文介绍在Linux下使用lspci命令查看PCI设备详细信息,也可以认为是lspci命令的功能介绍。
当前很多常用硬件都是PCI(Peripheral Component Interconnect)设备,如声卡、网卡、USB控制器等,稍老一点的显卡一般也是PCI设备。很可能由于要安装驱动或其它的需要查看PCI设备的详细信息。linux中的lspci命令方便地实现了这一点。
lspci最简单的使用方法是:
$lspci
它显示出通常对我们最有用的信息。
如果要更的详细信息,可以:
$lspci -v
$lspci -vv
$lspci -vvv
如果有的项目不能正常翻译成人能理解的文字,可以
$update-pciids
请确认您已连到互联网,能访问国外网。
Labels: depmod, ipp2p, iptables, lsmod, lspci, modprobe, network
Freebsd下普通用户使用sudo执行命令
cd /usr/ports/security/sudo
make install clean
ee /usr/local/etc/sudoers
修改
# %wheel ALL=(ALL) NOPASSWD: ALL
为
%wheel ALL=(ALL) NOPASSWD: ALL
这样whell组用户就可以通过sudo执行所有命令,且不需要输入密码。
给普通用户使用bash
cd /usr/ports/shells/bash
make install clean
默认bash路径为/usr/local/bin/bash
在用户home目录下建立.bash_profile和.bashrc提高用户使用bash的方便程度
ee .bash_profile
添加
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
ee .bashrc
添加
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ll='ls -lA'
source .bash_profile
source .bashrc
顺便提一下freebsd默认的csh是不带tab补全的,使用起来十分不方便,可以通过修改/etc/csh.cshrc
添加
set autolist
使用chkrootkit工具保护服务器(转)
Saturday, October 4, 2008
在保护linux 服务器时除了Tripwire 这样强大工具外,还有一个简单又好用的工具–chkrootkit。chkrootkit 顾名思义是监测系统是否被安装了rootkit 的一个安全工具。
安装chkrootkit,你可以自己去 http://www.chkrootkit.org/download/ 下载源码包,然后自己编译,也可以和我一样偷懒用别人做好的二进制包.
centos 下用非官方源安装chkrootkit:
首先添加dag 源for centos(我的系统是centos5.2)
# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
# rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
yum 安装chkrootkit
# yum update
# yum install chkrootkit
chkrootkit的应用
chkrootkit 的使用非常简单直接运行 chkrootkit 命令,然后会有如下输出
ROOTDIR is `/’
Checking `amd’… not found
Checking `basename’… not infected
Checking `biff’… not found
Checking `chfn’… not infected
Checking `chsh’… not infected
Checking `cron’… not infected
Checking `crontab’… not infected
Checking `date’… not infected
Checking `du’… not infected
Checking `dirname’… not infected
Checking `echo’… not infected
Checking `egrep’… not infected
Checking `env’… not infected
.
.
.
如果有rootkit会报“INFECTED” 所以可以直接用chkrootkit -n|grep ‘INFECTED’更直接一些。
定时检测并在出问题时给管理员发邮件。
创建如下脚本chkrootkit.sh并放入crontab 定时运行。
# cat chkrootkit.sh
#!/bin/bash
PATH=/usr/bin:/bin
TMPLOG=`mktemp`
# Run the chkrootkit
/usr/bin/chkrootkit > $TMPLOG
# Output the log
cat $TMPLOG | logger -t chkrootkit
# bindshe of SMTPSllHow to do some wrongs
if [ ! -z "$(grep 465 $TMPLOG)" ] && \
[ -z $(/usr/sbin/lsof -i:465|grep bindshell) ]; then
sed -i ‘/465/d’ $TMPLOG
fi
# If the rootkit have been found,mail root
[ ! -z "$(grep INFECTED $TMPLOG)" ] && \
grep INFECTED $TMPLOG | mail -s “chkrootkit report in `hostname`” root
# chmod 700 chkroot.sh
# mv chkrootkit /etc/cron.daily
这样系统会每天运行chkrootkit 检测系统,并在检测到rootkit 时给root 发一封邮件。
把给root 用户的系统邮件转发的管理员的gmail 邮箱
虽然可以登陆到系统去看系统邮件,但显然能用gmail 查看是更方便的选择。
1.安装sendmail 邮件转发要用到sendmail,
# yum sendmail
# /etc/intit.d/sendmail start (sendmail服务)
2.设置转发,编辑/etc/aliases,在文件最后加入
root: youname@gmail.com 然后运行newaliases 命令更新aliases
这样系统就会把给root 的邮件转发的你gmail 邮箱里去了。
本文中严重参考入侵监测系统的构建( chkrootkit ) 一文,感谢该文作者的工作。