CentOS建立DHCP服务1——安装dhcp
OPTION 1:
一、安装dhcp
|
1 |
yum install dhcp |
二、打开并修改配置文件etc/dhcpd.conf
1. 复制配置范例/usr/share/doc/dhcp*/dhcpd.conf.sample到前述文件
2. 修改配置文件中内容
主要是域信息和子网信息
三、重启服务&开机自启动
|
1 2 |
service dhcpd restart chkconfig dhcpd on |
打完收工
reference:http://debugo.com/linux-dhcpd/
2014年6月12日 Linux 0 Read more >
linux使用lvm管理磁盘
这文有比较详细的lvm介绍http://www.cnblogs.com/gaojun/archive/2012/08/22/2650229.html
〇、安装新磁盘
假设新磁盘是系统安装的第二块磁盘。
|
1 2 3 4 5 |
#检查新磁盘并创建分区 fdisk /dev/sdb #/dev/sda 是默认的第一块磁盘 #为新分区格式化(可能会很慢,耐心) mkfs.ext4 /dev/sdb |
一、使用fdisk添加未分区的磁盘空间。
【1】.新分区
fdisk <磁盘挂载地址>
1. n 新建分区
2. p 选择主分区
3. 分配剩余空间
4. w 保存
【2】.直接扩容原有分区
fdisk <磁盘挂载地址>
1. d 删除欲扩展的分区
2. n 新建分区(使用被删除的分区号)
3. p 选择主分区
4. 分配剩余空间
5. w 保存
二、使用partprobe更新分区表(不行就reboot)
三、lvm部分(详见链接介绍)
1. 创建pv(或者保留原有pv:pvresize <磁盘路径>)
2. 创建vg(或者扩展现有vg)
3. 创建lv(或者扩展现有lv)
|
1 2 3 4 5 6 7 8 9 10 11 12 |
#创建LV lvcreate -L 10G -n lv_ftp VolGroup00 #格式化磁盘 mkfs -t ext4 /dev/VolGroup00/lv_ftp #挂载 mount /dev/VolGroup00/lv_ftp /ftp #扩展LV lvextend –L 1G /dev/VolGroup00/LogVol01 #执行该重设大小,对于当前正在使用的LogVol01有效(可能会很慢,耐心!) resize2fs /dev/VolGroup00/LogVol01 #查看挂载情况,已经扩容 df –h |
4. 删除vg中挂载的磁盘(未将其分配给lv)
|
1 |
vgreduce VolGroup00 /dev/sda4 |
四、扩swap
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@test ~]# swapoff /dev/VolGroup/lv_swap [root@test ~]# lvextend -L +7G /dev/VolGroup/lv_swap Size of logical volume VolGroup/lv_swap changed from 3.88 GiB (992 extents) to 10.88 GiB (2784 extents). Logical volume lv_swap successfully resized [root@test ~]# mkswap /dev/VolGroup/lv_swap mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 11403260 KiB no label, UUID=9c380c5d-d3b0-43d2-8289-140c231e0ab8 [root@test ~]# swapon /dev/VolGroup/lv_swap [root@test ~]# free total used free shared buffers cached Mem: 32948356 423988 32524368 1384 19708 91408 -/+ buffers/cache: 312872 32635484 Swap: 11403260 0 11403260 |
windows 2008 r2加固
一、修改远程桌面端口3389为其他端口
1.regedit
2.修改[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds \rdpwd\Tds \tcp] PortNumber
3。修改[HKEY_LOCAL_MACHINE\SYSTEM\CurrentContro1Set\Control\Tenninal Server\WinStations\ RDP\Tcp] PortNumber
二、打开ping
服务器管理器 -> 高级安全windows防火墙 -> 出站规则 -> 文件和打印机共享(回显…)
三、账户策略
1.密码策略:永不过期,取消复杂性检测
2.账户锁定:锁定阈值为错误5次,锁定时间为30min
四、屏幕保护
15min无操作进入屏幕保护,解除需要密码
五、允许远程桌面连接
Vmware vSphere让本地和虚拟机可以通过复制和粘贴操作
原文:http://www.2cto.com/os/201108/99003.html
默认情况下,Vmware vSphere已禁用针对ESXESXi的复制和粘贴操作,以防止公开已复制到剪贴板中的敏感数据。其实可以通过设置启用它,具体操作如下:
1、使用vSphere Client 登录到vCenter Server 系统并选择虚拟机,虚拟机要在关闭状态下。
2 、选中虚拟机,单击右键编辑设置。
3、选择选项> 高级> 常规,然后单击配置参数。
4、 单击添加行,并在“名称”和“值”列中键入以下值。名称值
isolation.tools.copy.disable false
isolation.tools.paste.disable false
5、 单击确定以关闭“配置参数”对话框,然后再次单击确定以关闭“虚拟机属性”对话框。
6、重新启动虚拟机。
Scala初探
函数文本的语法就是,括号里的命名参数列表,右箭头,然后是函数体。
2014年5月29日 Linux 0 Read more >
RHEL6.* Server Security Hardening
师父:
http://debugo.com/rhel6-server-security-hardening-script/
不认识:
profile:http://linux.chinaitlab.com/administer/820910.html
- disabling services
原则:只保留最小化安装(不包含可视化桌面的那个最小)的系统服务+用户安装的服务。其他服务一律干掉。(附非官方最小安装服务列表:http://jiaxl.blog.51cto.com/3064605/954239)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
chkconfig NetworkManager off chkconfig abrt-ccpp off chkconfig abrtd off chkconfig acpid off chkconfig atd off chkconfig bluetooth off chkconfig certmonger off chkconfig cpuspeed off chkconfig cgconfig off chkconfig cpuspeed off chkconfig ip6tables off chkconfig iptables off chkconfig libvirt-guests off chkconfig netconsole off chkconfig netfs off chkconfig nfslock off chkconfig postfix off chkconfig rpcgssd off chkconfig rpcidmapd off chkconfig rhnsd off chkconfig restorecond off chkconfig httpd off chkconfig vsftpd off |
- config ntp client
|
1 2 |
crontab -e 38 * * * * /usr/sbin/ntpdate 172.18.5.193 >>/root/ntpdate.log 2>&1 |
ps:
38 ****这个火星文是cron的定时接口。详情见链接:
http://www.poluoluo.com/jzxy/201009/94264.html
ps:crontab 的数字前加“*/10”,则为每隔这些时间就执行一次。
>和>>都是重定向输出
1> 指标准信息输出路径(也就是默认的输出方式)
2> 指错误信息输出路径
2>&1 指将标准信息输出路径指定为错误信息输出路径(也就是都输出在一起)
补充问题4<&0:
<和<<都是重定向输入
<0指标准输入路径
4<&0 指的是将文件描述符4指定为标准输入(实际可选4到9之间任意一个数字)
习惯上
标准输入(standard input)的文件描述符是 0
标准输出(standard output)是 1
标准错误(standard error)是 2
> 会覆盖已有的文件内容,而>>会附加到已有内容之后。
- global env variables
这是为了永久修改时区
|
1 2 3 4 5 |
vim /etc/profile # adding. export TZ=Asia/Shanghai export TMOUT=1800 comment if-clause of umask statement,and use 'umask 022' to replace it. |
ps:
在.profile中使用export语句,它的作用是将变量设置在SHELL环境中,以在任意路径下使用。
comment :說明而已!好像是设置了新建文件的权限。
- use pam(可插拔认证模块 Pluggable Authentication Modules)(还是有待学习)
控制能su到root的用户。
|
1 2 3 4 5 6 7 8 9 |
vim /etc/pam.d/su: auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. # auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "wheel" group. auth required pam_wheel.so use_uid # only users in wheel group can su to root # you can modify user to wheel group like this: usermod -G10 username # then check: /etc/groups |
关于PAM的入门介绍:http://www.infoq.com/cn/articles/linux-pam-one
- password policy
|
1 2 3 4 5 6 7 8 9 |
(1)/etc/pam.d/passwd password include system-auth # include 表示在验证错误时,系统会跳出当前登入 # substack 表示在验证错误时,不会提示用户是在这一步错误了,直到所有验证步骤结束返回错误信息。 (2)修改文件/etc/pam.d/system-auth password requisite pam_cracklib.so minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 # minlen the length of password # lcredit ucredit dcredit ocredit表示小写、大写、数字、符合,设定值为为负数如-1表示至少1个,为正数如3表示最多3个 |
- create user without creating home
这个文件给出了对用户的一系列定义:
CREATE_HOME 是否为新建用户创建home目录
UMASK 用户新建文件的权限
|
1 2 3 |
/etc/login.defs CREATE_HOME no UMASK 027 |
- /etc/ssh/sshd_config
|
1 2 3 |
PermitRootLogin no MaxAuthTries 3 MaxSessions 5 |
- lock accounts
需要锁定的账号:adm、lp、sync、shutdown、halt、mail、news、uucp、operator、games、gopher、ftp、mailnull、
nfsnobody、nobody、pegasus、http
参考配置
(1)***用户:#userdel username;
(2)锁定用户:#passwd -l username
(3)解锁用户:#passwd -u username
(4)禁止用户交互登录:修改/etc/passwd文件,用户shell修改为/sbin/nologin
补充说明
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
passwd -l adm passwd -l lp passwd -l sync passwd -l shutdown passwd -l halt passwd -l mail passwd -l news passwd -l uucp passwd -l operator passwd -l games passwd -l gopher passwd -l ftp passwd -l mailnull passwd -l nfsnobody passwd -l nobody passwd -l pegasus passwd -l http |
- banner
这是发挥逗比技能的舞台 = =。系统登录时的banner 。。。也是只针对文本界面的。。。
|
1 2 |
#vim /etc/motd (message of the day) Authorized users only. All activities will be monitored and reported. |
ftp的配置文件/etc/vsftpd/vsftpd.conf
配置文件的全部技能:http://blog.csdn.net/yichi7758/article/details/4640014
ftp的banner:
|
1 2 |
#vim /etc/vsftpd/vsftpd.conf ftpd_banner="Authorized users only.All activity may be monitored and reported." |
ftp的匿名登录:
|
1 |
anonymous_enable=NO |
- disable Control-Alt-Delete
修改/etc/init/control-alt-delete.conf文件,注释如下内容:
|
1 |
exec /sbin/shutdown -r now "Control-Alt-Delete pressed" |
ps:这一行只是针对费图形界面进行配置。图形界面依然可以激活重启对话框。
- syslog
|
1 2 3 4 5 6 7 |
#vim /etc/rsyslog.conf *.err;kern.debug;daemon.notice; /var/log/messages(直接添加行) authpriv.* /var/log/secure(已经有了,确定一下) 重启syslog服务 /etc/init.d/rsyslog restart 修改log目录权限 #chmod 640 -R /var/log/ |
- selinux
关了
|
1 2 |
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 |
- iptables
也关了
|
1 2 |
service iptables stop service ip6tables stop |
CentOS网卡无法引导启动
原文链接:http://blog.sina.com.cn/s/blog_77126fa501018s3d.html
device eth0 does not seem to be present, delaying initialization
vmlite虚拟机启动出错,就把这个虚拟机删除掉重新建立,系统虚拟硬盘使用之前的,启动系统后不能上网,通过ifconfig查看网卡没启动,遂启动网卡服务,但是出错,就是:device eth0 does not seem to be present, delaying initialization,然后想到是不是ifcfg-eth0的配置文件里保存了以前的MAC地址,就把这一行删除掉在重启网卡,还是一样的错误,随后网上查了下资料,把/etc/udev/rules.d/70-persistent-net.rules 删除后重启机器就可以了,因为这个文件绑定了网卡和mac地址,所以换了网卡以后MAC地址变了,所以不能正常启动,也可以直接编辑这个配置文件把里面的网卡和mac地址修改乘对应的,不过这样多麻烦,直接删除重启,它会自动生成个。
1、
vi /etc/sysconfig/network-scripts/ifcfg-eth0
ifcfg-eth0的配置文件里保存了以前的MAC地址,就把这一行删除掉在重启网卡
2、
/etc/udev/rules.d/70-persistent-net.rules 删除后重启机器
因为这个文件绑定了网卡和mac地址,所以换了网卡以后MAC地址变了,所以不能正常启动,也可以直接编辑这个配置文件把里面的网卡和mac地址修改乘对应的,不过这样多麻烦,直接删除重启,它会自动生成个。
2014年5月27日 Linux 0 Read more >
CentOSrsyslog服务器与客户端搭建
参考链接:
官网:
http://www.rsyslog.com/storing-messages-from-a-remote-system-into-a-specific-file/
http://www.rsyslog.com/sending-messages-to-a-remote-syslog-server/
http://www.rsyslog.com/doc/v5-stable/tutorials/log_rotation_fix_size.html#conclusion
师父:
http://debugo.com/linux-note-rsyslog/
不认识:
http://blog.csdn.net/hxh129/article/details/8089474(有详细的配置文件翻译)
-
服务器端:
1.安装rsyslog
2.编辑/etc/rsyslog.conf: 打开UDP、TCP监听
3.创建/etc/rsyslog.d/remoteserver.conf(写在这个文件中的规则,放在/etc/rsyslog.conf中也可生效。分文件是便于管理)
可用规则1:为每一个主机(IP)配规则
|
1 |
:fromhost,isequal, “debugo02″ /var/log/remoteserver.log |
可用规则2:为一个IP Group配规则
|
1 2 3 4 5 6 7 8 9 |
$ModLoad imtcp $InputTCPServerRun 10514 # do this in FRONT of the local/regular rules if $fromhost-ip startswith '192.0.1.' then /var/log/network1.log & ~ if $fromhost-ip startswith '192.0.2.' then /var/log/network2.log & ~ # local/regular rules, like *.* /var/log/syslog.log |
4.重启rsyslog服务:service rsyslog restart
-
客户端:
1.安装rsyslog
2.编辑/etc/rsyslog.conf: 将remote host行取消注释并填入rsyslog server IP:
|
1 2 |
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional *.* @@remote_server_ip:514 |
3.测试:logger “hello world”。根据server端配置路径查看日志内容。
-
logrotate
1.使用基于cron服务的logrotate(可man)
2.配置范例在文件/etc/logrotate.conf
3.用户自定义配置,使用/etc/logrotate.conf中提供的方法,并将配置文件放在/etc/logrotate.d/下面
打完收工
2014年5月27日 Linux 0 Read more >
使用ftp建立yum源
-
server端
-
建立ftp服务
-
建立vsftpd服务
-
createrepo /repo
-
-
reposync远程源到本地
-
client端
2014年5月26日 Linux 0 Read more >
windows 08 修改密码策略
gpedit.msc
计算机配置-Windows设置-安全设置-帐户策略-密码策略