10、通过PAM完成以下功能:
(1)禁止root用户在tty6终端登录;
(2)设置Ubuntu用户登录系统后所能够打开的文件个数硬限制为200,软限制为120;
(3)设置develop组中的用户登录系统后所能够运行的进程数的硬限制为300,软限制为200;
参考答案:
# vi /etc/pam.d/system-auth
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
# vi /etc/securetty
删除tty6
# vi /etc/security/limits.conf
ubuntu soft nofile 120
ubuntu hard nofile 200
# vi /etc/security/limits.conf
@develop soft nproc 200
@develop hard nproc 300
11、设置telnet服务,要求:
(1)仅允许来自于192.168.0.0/24中的主机访问此服务;
(2)每个IP所能够发起的并发连接请求最多为6个;
(3)此服务所接受的最大并发连接数为20,达到20时则暂停提供服务10秒钟;
参考答案:
# vi /etc/xinetd.d/telnet
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
only_from = 192.168.0.0/24
per_source = 6
instances = 20
cps = 20 10
}
12、设定本机对ping请求的响应:
(1)本机仅接受来自于172.16.0.0/16网络的ping请求,且请求频度每秒不能超过10个;
(2)本机可以向其它任意主机发起Ping请求;
参考答案:
# iptables -A INPUT -s 172.16.0.0/16 -p icmp --icmp-type 8 -m limit --limit 8/second --limit-burst 10 -j ACCEPT
# iptables -A OUTPUT -s 172.16.0.0/16 -p icmp --icmp-type 0 -j ACCEPT
# iptables -A OUTPUT -p icmp --icmp-type 8 -j ACCEPT
# iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
