pavement

Sysctl.conf Security Knobs

From FreeBSDwiki
Revision as of 13:34, 6 August 2012 by 173.88.199.104 (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sysctl.conf Security Knobs

Add the following statements to the /etc/sysctl.conf file. You can drop the comments, but I always find them helpful later when I am looking for a problem.


  1. The sysctl.conf file contains MIB's to change the default setting
  2. of internal options of the kernel at boot up time. These MIB's
  3. control how network packets are handled after the IPFW or IPFILTER
  4. software application firewalls return the packet to the kernel.
  5. Some of these MIB's may seem like they are doing the same thing,
  6. but because there is no FBSD provided documentation on the order
  7. these MIB's get control, they all get enabled here and we let the
  8. kernel do its thing.
  9. NOTE: Some of these MIB's can also be set in rc.conf and/or the
  10. kernel source. This will not hurt anything.
  1. Redirect attacks are the purposeful mass issuing of ICMP type 5 packets.
  2. In a normal network, redirects to the end stations should not be required.
  3. To defend against this type of attack both the sending and accepting of
  4. redirect should be disabled. The first statement below enables the MIB
  5. to drop all inbound icmp redirect packets without returning any response.
  6. The second statement turns off the logging of redirect packets because
  7. there in no limit and this could fill up your logs consuming your whole
  8. hard drive. But there is no information about where the redirect packets
  9. get logged. The last statement changes the FBSD default about allowing
  10. redirects to be sent from this system to the Internet from yes to no.
  11. This option is ignored unless the host is routing IP packets, and
  12. should normally be enabled (=1) on all systems
  13. man icmp(4) and inet(4) and man ip(4) do not contain info about these MIBs.
  14. man sysctl(3) does have info on ip.redirect

net.inet.icmp.drop_redirect=1 net.inet.icmp.log_redirect=0 net.inet.ip.redirect=0


  1. Source routing is another way for an attacker to try to reach non-routable
  2. addresses behind your box. It can also be used to probe for information
  3. about your internal networks. These functions come enabled as part of the
  4. standard FBSD core system. The following will disable them.
  5. man inet(4) and man ip(4) do not contain any information on these MIBs.

net.inet.ip.sourceroute=0 net.inet.ip.accept_sourceroute=0


  1. This MIB only drops ICMP echo requests which have a destination of your
  2. broadcast address. For example, if your network is 10.10.0.1/24,
  3. (making your subnet mask 255.255.255.0) then your network broadcast address
  4. is 10.10.0.255. When a host on your network needs to send a message to all
  5. other hosts on the subnet (which happens more often than you may think) it
  6. uses this address. Everyone listens on it. Hosts outside your network have
  7. no reason to be sending packets to your broadcast address. This MIB rejects
  8. all of the broadcast echo traffic from the outside world to your network
  9. broadcast address. If this host is a firewall or gateway, it should not
  10. propagate directed broadcasts originating from outside your private network.
  11. The following statement sets the default to no, rejecting all external
  12. broadcasts requests.
  13. man sysctl(3) has some info.
  14. man inet(4) and man icmp(4) do not contain any information on these MIBs.

net.inet.icmp.bmcastecho=0


  1. This changes the system behavior when connection requests are received
  2. on TCP or UDP ports where there is no socket listening. The normal
  3. behavior, when a TCP SYN segment is received on a port where there
  4. is no socket accepting connections is for the system to return a
  5. RST segment and drop the connection. The requesting system will
  6. see this as a "Connection reset by peer".
  7. By turning the TCP black hole MIB on with a numeric value of one, the
  8. incoming SYN segment is merely dropped, and no RST is sent, making
  9. the system appear as a blackhole.
  10. By setting the MIB value to two, any segment arriving on a closed
  11. port is dropped without returning a RST.
  12. This provides some degree of protection against stealth port scans.
  13. The following enables this MIB. man tcp(4) and man udp(4) blackhole(4)
  14. contain a little information on these MIBs.

net.inet.tcp.blackhole=2 net.inet.udp.blackhole=1


  1. The log_in_vain MIB will provide you with logging of attempted
  2. connections to your box on any port which does not have a service
  3. running on it. For example, if you do not have DNS server on your
  4. computer and someone would try to access your computer through DNS
  5. port 53, you would see a message such as: Connection attempt to
  6. UDP yourIP:53 from otherIP:X (where X is some high port #) displayed
  7. on the root console screen. This message also gets posted to
  8. /var/log/messages & /var/log/security.log.
  9. The following statements enable this function.
  10. man tcp(4) and man udp(4) contain a little information on these MIBs.

net.inet.tcp.log_in_vain=1 net.inet.udp.log_in_vain=1


  1. To defend against SYN attacks more commonly known as SYNFLOOD attacks,
  2. the two queues which are targeted by this type of attack should
  3. have their size increased so that the queues can withstand an attack
  4. of low to moderate intensity with little to no effect on the stability
  5. or availability of the system. FBSD maintains separate queues for
  6. inbound socket connection requests. One queue is for half-open sockets
  7. (SYN received, SYN|ACK sent), and the other queue for fully-open sockets
  8. awaiting an accept() call from the application.
  9. The following statement increases the queue size from 128.
kern.ipc.somaxconn=1024 


  1. By allowing aged ARP entries to remain cached or lying around
  2. allows for the possibility of a hacker to create a resource
  3. exhaustion or performance degradation by filling the IP route cache
  4. with bogus ARP entries. This in turn can be used as a Denial of
  5. Service attack. To prevent this sort of problem, the following
  6. statement shortens the amount of time an ARP will be cached
  7. from 1200 to 600 seconds.

net.link.ether.inet.max_age=600

Personal tools