Using lsof to list all of the TCP and UDP listening sockets.

lsof - list open files

# lsof -i -n | egrep ‘COMMAND|LISTEN|UDP|TCP’
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
avahi-dae 3220 avahi 13u IPv4 7403 UDP *:mdns
avahi-dae 3220 avahi 14u IPv4 7408 UDP *:58607

Detecting Listening Network Ports

One of the most important tasks is to detect and close network ports that are not needed.

To get a list of listening network ports (TCP and UDP sockets), you can run the following command:

netstat -tulp

Running a port scan from another server. (make sure that you have permissions to probe a machine):

# nmap -sTU

How to turn on spoof protection

To turn on spoof protection, run a simple bash script:

for i in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 1 > $i done;

Sysctl Hardening Modifies kernel operating values to strengthen TCP/IP stack against various attacks including syn floods.

sysctl.conf is a simple file containing sysctl values to be read in and set by sysctl(8)

EXAMPLES

/sbin/sysctl -a
/sbin/sysctl -n kernel.hostname
/sbin/sysctl -w kernel.domainname=”example.com”
/sbin/sysctl -p /etc/sysctl.conf

TCP_SYNCookies protection

A SYN-flood attack has the ability to bring the network aspect of your linux box to a snail like crawl. TCP_SYNCookies protection attempts to stop this from taking a heavy toll on the machine. To enable tcp_syncookies protection, use the following command:

echo 1 > /proc/sys/net/ipv4/tcp_syncookies

If it’s not enabled, there isn’t much you can do other than build a new kernel and reboot and use it.

Find if ssl certificate and key are paired correctly.

To view the contents of a certificate:

openssl x509 -noout -text -in filename.crt

To view the contents of a private key:

openssl rsa -noout -text -in filename.key

If the modulus number and exponent of the cert and key match, they are paired correctly. If not, they are mismatched and apache will not start with ssl enabled.

« Prev - Next »