ubuntu14.04系统加固(3)

说明:因工作需要,特此写本博文,方便以后查阅。如文中有问题之处,望指点,拍砖请轻拍,谢谢合作。
/*****************************************************************************
*加固系统:ubuntu14.04
******************************************************************************/
一、禁止icmp重定向
加固步骤:
1、备份文件:
root@xxx:/# cp -p /etc/sysctl.conf /etc/sysctl.conf.bak
2、执行:
root@xxx:/# vim /etc/sysctl.conf
加上net.ipv4.conf.all.accept_redirects=0
也可以用以下命令修改net.ipv4.conf.all.accept_redirects的值为0
sysctl -w net.ipv4.conf.all.accept_redirects=0
二、主机SSH访问控制(IP限制)
加固步骤:
1、执行备份:
root@xxx:/# cp -p /etc/hosts.allow /etc/hosts.allow.bak
root@xxx:/# cp -p /etc/hosts.deny /etc/hosts.deny.bak
2、编辑/etc/hosts.allow和/etc/hosts.deny两个文件,文件的配置格式为:
Service:host [or network/netmask],host [or network/netmask]
root@xxx:/# vim /etc/hosts.allow
增加一行 service: 允许访问的IP,举例如下:
all:192.168.4.44:allow #允许单个IP访问所有服务进程
sshd:192.168.1.:allow #允许192.168.1的整个网段访问SSH服务进程
root@xxx:/# vim /etc/hosts.deny
增加一行 sshd:all:DENY 当设置了hosts.allow之后hosts.deny不再起作用。
三、配置远程日志保存
加固步骤:
1、执行备份:
root@xxx:/# cp -p /etc/rsyslog.d/50-default.conf /etc/ rsyslog.d/50-default.conf.bak
2、修改50-default.conf文件
root@xxx:/# vim / etc/rsyslog.d/50-default.conf
新增. @192.168.0.1 行,192.168.0.1为远程日志服务器ip
root@xxx:/# /etc/init.d/rsyslog restart
四、使用内置防火墙iptables来过滤流量
加固步骤:
方法一:
1、查看iptables的状态
root@xxx:/# iptables-save
2、增加iptables访问控制策略
root@xxx:/# iptables -A INPUT -p tcp -dport 22 -m state --state NEW -j ACCEPT
root@xxx:/# iptables -A INPUT -m state -state RELATE,ESTABLISTED -j ACCEPT
root@xxx:/# iptables -A INPUT -j DROP
以上策略为只允许远程主机主动访问服务器ssh端口,而服务器可以主动向外访问所有端口。
方法二:
由于加固过程中按照方法一老是会出现问题,参数也比较复杂,下面可以使用一个小工具ufw来调用iptables来设置;
1、启用ufw
root@xxx:/# ufw default deny
root@xxx:/# ufw enable
2、开启/禁用
ufw allow|deny [service]
打开或关闭某个端口,例如:
root@xxx:/# ufw allow smtp #允许所有的外部IP访问本机的25/tcp (smtp)端口
root@xxx:/# ufw allow 22/tcp #允许所有的外部IP访问本机的22/tcp (ssh)端口
root@xxx:/# ufw allow 222 #允许所有的外部IP访问本机的222(tcp/udp)
root@xxx:/# ufw allow 9080 #允许外部访问9080端口(tcp/udp)
root@xxx:/# ufw deny smtp #禁止外部访问smtp服务
root@xxx:/# ufw delete allow smtp #删除上面建立的某条规则
3、查看防火墙状态
root@xxx:/# ufw status
4、关闭ufw
root@xxx:/# ufw disable

感谢博客:http://www.cnblogs.com/ylan2009/articles/2321136.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值