RHEL/CentOS Server Security

As a part of the sys admin’s job, it is important to take a few extra minutes to go through and properly secure a newly installed Linux server. These steps include enabling SELinux on the machine, configuring the firewall, and setting user permissions. There are however additional steps one should take in order to secure their server. One would be to tune and secure kernel parameters, set limits on kernel dumps, prevent IPv6 from loading if you company is not using it, and turning off unnecessary services.


First, lets take a look at configuring kernel parameters to prevent network based attacks. These include disallowing intruders to alter routing tables and source routed packets, preventing an intruder from configuring the server to become a router, and turning on reverse path filtering. To change these settings edit the /etc/sysctl.conf file and enter:

    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.all.log_martians = 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 

    net.ipv4.icmp_ignore_bogus_error_messages = 1 

    net.ipv4.tcp_syncookies = 1 

    net.ipv4.conf.all.rp_filter = 1 

   net.ipv4.conf.default.rp_filter = 1 

If you are currently running IPv6 at your company, here are a few kernel parameters to prevent network based attacks:

    net.ipv6.conf.default.router_solicitations = 0 

    net.ipv6.conf.default.accept_ra_rtr_pref = 0 

    net.ipv6.conf.default.accept_ra_pinfo = 0 

    net.ipv6.conf.default.accept_ra_defrtr = 0 

    net.ipv6.conf.default.autoconf = 0 

    net.ipv6.conf.default.dad_transmits = 0 

    net.ipv6.conf.default.max_addresses = 1 

To make these settings effective without rebooting the server type sysctl -p 

We can go a step further by disabling unused network functions such as IPv6 and prevent self assigned addressing.

To detect whether or not IPv6 is running on a server type: ifconfig | grep inet6 which will return:

    inet6 addr: fe80::240:5ff:fe32:ef19/64 Scope:Link 

    inet6 addr: ::1/128 Scope:Host 

    inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link 

To prevent IPv6 from loading, run the following command:

echo install ipv6 /bin/true > /etc/modprobe.d/ipv6 

Then add the following lines to /etc/sysconfig/network:



This will deactivate the IPv6 protocol from running on the server.

To prevent self assigned addressing on network cards, open the /etc/sysconfig/network file and add:


Server security 

Turning off the ability to create core dumps is important as intruders can use this to gather information about running services and configurations in order to exploit them. To do so, edit the /etc/security/limits.conf file and insert:

* hard core 0 

We should also prevent setuid programs from creating these as well:

sysctl -w fs.suid_dumpable=0 

There are also built in kernel features which can help protect against buffer overflow attacks. These features are turned on by default, however these kernel parameters should be enabled in case they have been turned off:

    sysctl -w kernel.exec-shield=1 

    sysctl -w kernel.randomize_va_space=1 

These settings ensure randomization of the stack and memory regions, which are refereed to as the ExecShield.

There are many services which are running on a default installation which include cups, sendmail, isdn, bluetooth, and many others. If these services are not being used on the server then they should be turned off and configured not to start up on a reboot. To do so we can run the following bash script:

for i in acpid autofs avahi-daemon luetooth cups firstboot gpm hidd ip6tables sendmail exim xfs xinetd yum-updatesd rhnsd pcscd readahead_early readahead_later apmd hplip isdn ip6tables mcstrans 


    service $i stop 

    chkconfig $i off 


Your services will vary depending on the installation. We should also ensure that X does not run on reboot, placing the server in run level three. To do so, edit the /etc/inittab file and change id:5:initdefault: to id:3:initdefault:

Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.