HardenedBSD/etc/rc.d/netoptions

93 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: netoptions
# REQUIRE: FILESYSTEMS
# KEYWORD: nojail
. /etc/rc.subr
_netoptions_initdone=
netoptions_init()
{
if [ -z "${_netoptions_initdone}" ]; then
echo -n 'Additional TCP/IP options:'
_netoptions_initdone=yes
fi
}
load_rc_config 'XXX'
case ${log_in_vain} in
[Nn][Oo] | '')
log_in_vain=0
;;
[Yy][Ee][Ss])
log_in_vain=1
;;
[0-9]*)
;;
*)
netoptions_init
echo " invalid log_in_vain setting: ${log_in_vain}"
log_in_vain=0
;;
esac
if [ "${log_in_vain}" -ne 0 ]; then
netoptions_init
echo -n " log_in_vain=${log_in_vain}"
sysctl net.inet.tcp.log_in_vain="${log_in_vain}" >/dev/null
sysctl net.inet.udp.log_in_vain="${log_in_vain}" >/dev/null
fi
case ${tcp_extensions} in
[Yy][Ee][Ss] | '')
;;
*)
netoptions_init
echo -n ' tcp extensions=NO'
sysctl net.inet.tcp.rfc1323=0 >/dev/null
;;
esac
case ${tcp_keepalive} in
[Nn][Oo])
netoptions_init
echo -n ' TCP keepalive=NO'
sysctl net.inet.tcp.always_keepalive=0 >/dev/null
;;
esac
case ${tcp_drop_synfin} in
[Yy][Ee][Ss])
netoptions_init
echo -n ' drop SYN+FIN packets=YES'
sysctl net.inet.tcp.drop_synfin=1 >/dev/null
;;
esac
case ${ip_portrange_first} in
[Nn][Oo] | '')
;;
*)
netoptions_init
echo -n " ip_portrange_first=$ip_portrange_first"
sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
;;
esac
case ${ip_portrange_last} in
[Nn][Oo] | '')
;;
*)
netoptions_init
echo -n " ip_portrange_last=$ip_portrange_last"
sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
;;
esac
[ -n "${_netoptions_initdone}" ] && echo '.'