海运的博客

Linux/Centos服务器安装portsentry防恶意端口扫描

发布时间:June 28, 2012 // 分类:网络安全 // No Comments

端口做为服务器的大门安全很重要,当服务器运行很多服务时并向外提供服务,为防止有人恶意侦测服务器用途,可使用portsentry来迷惑对方。
portsentry可设定侦听指定的TCP/UDP端口,当遇到扫描时会回应端口开放,并记录扫描者信息可做相应处理:防火墙阻止、路由定向、执行自定义脚本。
portsentry安装之rpm:

rpm -ivh http://flexbox.sourceforge.net/centos/5/x86_64/portsentry-1.2-1.el5.x86_64.rpm

portsentry编译安装:

wget http://sourceforge.net/projects/sentrytools/files/portsentry%201.x/portsentry-1.2/portsentry-1.2.tar.gz
cd portsentry_beta/
#编辑portsentry.c修改以下为一行
#printf ("Copyright 1997-2003 Craig H. Rowland <craigrowland at users dot sourceforget dot net>\n"); 
make linux
make install

portsentry配置文件:

cat /usr/local/psionic/portsentry/portsentry.conf
#TCP和UDP模式监听的端口,可自定义
TCP_PORTS="1,11,15,79,111,119,143,540,635,1080,1524,2000,5742,6667,12345,12346,20034,27665,31337,32771,32772,32773,32774,40421,49724,54320"
UDP_PORTS="1,7,9,69,161,162,513,635,640,641,700,37444,34555,31335,32770,32771,32772,32773,32774,31337,54321"
#忽略IP
IGNORE_FILE="/usr/local/psionic/portsentry/portsentry.ignore"
#所有拒绝IP记录
HISTORY_FILE="/usr/local/psionic/portsentry/portsentry.history"
#启动后拒绝IP记录
BLOCKED_FILE="/usr/local/psionic/portsentry/portsentry.blocked"
#对扫描IP的操作,0为无动作,1防火墙阻止,2执行脚本
BLOCK_UDP="0"
BLOCK_TCP="0"
#路由数据包
KILL_ROUTE="/sbin/route add -host $TARGET$ gw 333.444.555.666"
#Iptables阻止
KILL_ROUTE="/usr/local/bin/iptables -I INPUT -s $TARGET$ -j DROP"
#TCP wrappers阻止
KILL_HOSTS_DENY="ALL: $TARGET$"
#执行脚本
KILL_RUN_CMD="/some/path/here/script $TARGET$ $PORT$"

portsentry启动模式:

/usr/local/psionic/portsentry/portsentry -tcp 
#TCP基本端口绑定,以配置文件端口为准
/usr/local/psionic/portsentry/portsentry -udp
#UDP基本端口绑定,以配置文件端口为准
/usr/local/psionic/portsentry/portsentry -stcp
#TCP私密检测,只记录不回应端口开放
/usr/local/psionic/portsentry/portsentry -sudp
#UDP私密检测,只记录不回应端口开放
/usr/local/psionic/portsentry/portsentry -atcp
#UDP高级秘密检测,自动选择监听端口
/usr/local/psionic/portsentry/portsentry -audp 
#UDP高级秘密检测,自动选择监听端口

以基本TCP检测模式启动,用nmap扫描测试:

[root@xenserver5 ~]# nmap -sS  www.haiyun.me
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-06-11 22:35 CST
Interesting ports on typecho.domain.com (192.168.1.2):
Not shown: 1654 closed ports
PORT      STATE SERVICE
1/tcp     open  tcpmux
11/tcp    open  systat
15/tcp    open  netstat
22/tcp    open  ssh
79/tcp    open  finger
80/tcp    open  http
111/tcp   open  rpcbind
119/tcp   open  nntp
143/tcp   open  imap
443/tcp   open  https
540/tcp   open  uucp
635/tcp   open  unknown
1080/tcp  open  socks
1524/tcp  open  ingreslock
2000/tcp  open  callbook
3306/tcp  open  mysql
6667/tcp  open  irc
12345/tcp open  NetBus
12346/tcp open  NetBus
27665/tcp open  Trinoo_Master
31337/tcp open  Elite
32771/tcp open  sometimes-rpc5
32772/tcp open  sometimes-rpc7
32773/tcp open  sometimes-rpc9
32774/tcp open  sometimes-rpc11
54320/tcp open  bo2k

查看防火墙阻止记录:

cat /etc/hosts.deny 
ALL: 192.168.1.6

XenServer限制虚拟机带宽、网络连接速度

发布时间:June 27, 2012 // 分类:虚拟化 // 2 Comments

XenServer可以在虚拟网络接口VIF上做带宽限制,设置如下:
为特定VIF设置QOS算法类型为ratelimit(速率限制)

xe vif-param-set uuid=<vif-uuid> qos_algorithm_type=ratelimit

设置VIF带宽参数:

xe vif-param-set uuid=<vif-uuid> qos_algorithm_params:kbps=5120
限制VM网络速率5120K,相当于带宽40M.

XenServer虚拟机CPU优先级设置

发布时间:June 27, 2012 // 分类:虚拟化 // No Comments

首先获取XenServer虚拟机UUID:

xe vm-list name-label=www.haiyun.me params=uuid --minimal

1.设置VM虚拟机的权重,权重较高的VM优先占用CPU。

xe vm-param-set uuid=<vm_uuid> VCPUs-params:weight=1024
#将优先级调整为1024,可选范围1-65535,数值越大优先级超高,默认值为 256。

2.设置VM的CPU最大使用率:

xe vm-param-set uuid=<vm_uuid> VCPUs-params:cap=200
#限制CPU上限200%,默认为0.

3.也可设置XenServer虚拟机使用特定CPU:

xe vm-param-set uuid=<vm_uuid> VCPUs-params:mask=6,7,8
#指定VM使用物理CPU6,7,8

调整XenServer虚拟机CPU个数:https://www.haiyun.me/archives/xenserver-vm-cpu.html

XenServer修改虚拟机时间

发布时间:June 27, 2012 // 分类:虚拟化 // No Comments

Xenserver下虚拟机默认同步主服务器时钟,使用date自定义时间无效。
解决方法:

sysctl xen.independent_wallclock=1

也可将此参数添加到sysctl配置文件:

vim /etc/sysctl.conf
xen.independent_wallclock=1

生效:

sysctl -p

XenServer添加/扩充虚拟机VM硬盘

发布时间:June 27, 2012 // 分类:虚拟化 // No Comments

1.添加虚拟机硬盘,首先查看所新建硬盘所在sr-uuid:

xe sr-list

新建VDI:

xe vdi-create sr-uuid=<sr-uuid> type=user virtual-size=1GiB name-label=<vdi-name>
b9fa32eb-3041-4f82-8e67-f2e2fa8baf8f #新建的vdi-uuid

新建VBD:

xe vbd-create vdi-uuid=<vdi-uuid>  vm-uuid=<vm-uuid> device=1 VM硬盘编号,从0开始
2f25f904-24c9-bf2b-eca4-86fab90f769e #新建的vbd-uuid

应用VBD:

xe vbd-plug uuid=<vbd-uuid>

VDI与VBD的关系:https://www.haiyun.me/archives/xenserver-sr-vdi.html
2.扩充虚拟机硬盘,首先关闭要扩充硬盘的虚拟机.

xe vm-shutdown vm=<vmname>

查看要增加容量的vdi-uuid:

xe vm-disk-list vm=<vmname>

扩充容量:

xe vdi-resize uuid=<vdi-uuid> disk-size=30GiB

扩充完成,然后重新启动虚拟机,进入系统将硬盘扩充到虚拟机。

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...
归档