-
Notifications
You must be signed in to change notification settings - Fork 1
/
harden_05_rhel5_cis-v1.1.1.sh
113 lines (82 loc) · 3.98 KB
/
harden_05_rhel5_cis-v1.1.1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
#
# harden_05_rhel5_cis-v1.1.1sh
##########################################################################
# AUTHOR: Jack Maynard #
# Created: May 10, 2010 - version 1.0 #
# #
# RHEL5 Hardening Script Section 5.0 - System Network Parameter Tuning #
# Scripted to Center for Internet Security (CIS) RHEL5 Benchmark v1.1.1 #
# www.cisecurity.org #
##########################################################################
# Variable Declarations
# Redirect stdout and stderr to /dev/null, this helps reduce screen noise.
# Change /dev/null to a real file for debugging purposes.
STDOUT_STDERR="/dev/null"
exec &>${STDOUT_STDERR}
##########################################################################
# #
# RHEL5 Benchmark Section 5.0 #
# System Network Parameter Tuning #
# #
##########################################################################
##########################################################################
# 5.1 - Network Parameter Modifications #
##########################################################################
modify_net_params(){
cat <<END_SCRIPT >> /etc/sysctl.conf
# The following 11 lines added, per
# CIS RHEL5 Benchmark v1.1.1 sec 5.1:
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
END_SCRIPT
chown root:root /etc/sysctl.conf
chmod 0600 /etc/sysctl.conf
# Load new sysctl setting from /etc/sysctl.conf
sysctl -p
}
##########################################################################
# 5.2 - Additional Network Parameter Modifications #
##########################################################################
additional_net_params(){
cat <<END_SCRIPT >> /etc/sysctl.conf
# The following 4 lines added, per
# CIS RHEL5 Benchmark v1.1.1 sec 5.2:
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.icmp_ignore_bogus_error_responses = 1
END_SCRIPT
chown root:root /etc/sysctl.conf
chmod 0600 /etc/sysctl.conf
# Load new sysctl setting from /etc/sysctl.conf
sysctl -p
}
#---------- BEGIN CONFIGURATION ----------#
# TO CHANGE SCRIPT BEHAVIOR ONLY EDIT THE SECTIONS BELOW THIS LINE !!!
##########################################################################
# #
# CONFIGURATION #
# Section 5.0 - System Network Parameter Tuning #
# #
##########################################################################
##########################################################################
# 5.1 - Network Parameter Modifications #
##########################################################################
modify_net_params
##########################################################################
# 5.2 - Additional Network Parameter Modifications #
##########################################################################
additional_net_params
#---------- END CONFIGURATION ----------#
#---------- END SECTION 5 ----------#
#END