1100280Sgordon#!/bin/sh 225184Sjkh# 350472Speter# $FreeBSD$ 466830Sobrien# 525184Sjkh 6117019Smtm# PROVIDE: netoptions 7169215Smtm# REQUIRE: FILESYSTEMS 8197143Shrs# BEFORE: netif 9136224Smtm# KEYWORD: nojail 1025184Sjkh 11100280Sgordon. /etc/rc.subr 12197646Sume. /etc/network.subr 1325184Sjkh 14197143Shrsname="netoptions" 15197143Shrsstart_cmd="netoptions_start" 16197143Shrsstop_cmd=: 17197143Shrs 18179940Smtm_netoptions_initdone= 19179940Smtmnetoptions_init() 20179940Smtm{ 21179940Smtm if [ -z "${_netoptions_initdone}" ]; then 22179940Smtm echo -n 'Additional TCP/IP options:' 23179940Smtm _netoptions_initdone=yes 24179940Smtm fi 25179940Smtm} 26179940Smtm 27197143Shrsnetoptions_start() 28197143Shrs{ 29197698Shrs local _af 30197698Shrs 31197698Shrs for _af in inet inet6; do 32197698Shrs afexists ${_af} && eval netoptions_${_af} 33197698Shrs done 34197698Shrs [ -n "${_netoptions_initdone}" ] && echo '.' 35197698Shrs} 36197698Shrs 37197698Shrsnetoptions_inet() 38197698Shrs{ 39197702Shrs case ${log_in_vain} in 40197702Shrs [12]) 41197143Shrs netoptions_init 42197143Shrs echo -n " log_in_vain=${log_in_vain}" 43220153Semaste ${SYSCTL} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null 44220153Semaste ${SYSCTL} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null 45197702Shrs ;; 46197702Shrs *) 47220153Semaste ${SYSCTL} net.inet.tcp.log_in_vain=0 >/dev/null 48220153Semaste ${SYSCTL} net.inet.udp.log_in_vain=0 >/dev/null 49197702Shrs ;; 50197702Shrs esac 5185831Sdes 52197143Shrs if checkyesno tcp_extensions; then 53220153Semaste ${SYSCTL} net.inet.tcp.rfc1323=1 >/dev/null 54197698Shrs else 55197143Shrs netoptions_init 56198383Shrs echo -n " rfc1323 extensions=${tcp_extensions}" 57220153Semaste ${SYSCTL} net.inet.tcp.rfc1323=0 >/dev/null 58197143Shrs fi 5965532Snectar 60197698Shrs if checkyesno tcp_keepalive; then 61220153Semaste ${SYSCTL} net.inet.tcp.always_keepalive=1 >/dev/null 62197698Shrs else 63197143Shrs netoptions_init 64198383Shrs echo -n " TCP keepalive=${tcp_keepalive}" 65220153Semaste ${SYSCTL} net.inet.tcp.always_keepalive=0 >/dev/null 66197143Shrs fi 67169217Smtm 68197143Shrs if checkyesno tcp_drop_synfin; then 69197143Shrs netoptions_init 70198383Shrs echo -n " drop SYN+FIN packets=${tcp_drop_synfin}" 71220153Semaste ${SYSCTL} net.inet.tcp.drop_synfin=1 >/dev/null 72197698Shrs else 73220153Semaste ${SYSCTL} net.inet.tcp.drop_synfin=0 >/dev/null 74197143Shrs fi 75169217Smtm 76197143Shrs case ${ip_portrange_first} in 77197143Shrs [0-9]*) 78197143Shrs netoptions_init 79197143Shrs echo -n " ip_portrange_first=$ip_portrange_first" 80220153Semaste ${SYSCTL} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null 81197143Shrs ;; 82197143Shrs esac 83169217Smtm 84197143Shrs case ${ip_portrange_last} in 85197143Shrs [0-9]*) 86197143Shrs netoptions_init 87197143Shrs echo -n " ip_portrange_last=$ip_portrange_last" 88220153Semaste ${SYSCTL} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null 89197143Shrs ;; 90197143Shrs esac 91197698Shrs} 92169217Smtm 93197698Shrsnetoptions_inet6() 94197698Shrs{ 95197698Shrs if checkyesno ipv6_ipv4mapping; then 96197698Shrs netoptions_init 97197698Shrs echo -n " ipv4-mapped-ipv6=${ipv6_ipv4mapping}" 98220153Semaste ${SYSCTL} net.inet6.ip6.v6only=0 >/dev/null 99197698Shrs else 100220153Semaste ${SYSCTL} net.inet6.ip6.v6only=1 >/dev/null 101197143Shrs fi 102212576Shrs 103212576Shrs if checkyesno ipv6_privacy; then 104212576Shrs netoptions_init 105212576Shrs echo -n " IPv6 Privacy Addresses" 106220153Semaste ${SYSCTL} net.inet6.ip6.use_tempaddr=1 >/dev/null 107220153Semaste ${SYSCTL} net.inet6.ip6.prefer_tempaddr=1 >/dev/null 108212576Shrs fi 109225521Shrs 110225521Shrs case $ipv6_cpe_wanif in 111225521Shrs ""|[Nn][Oo]|[Nn][Oo][Nn][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) 112225521Shrs ${SYSCTL} net.inet6.ip6.no_radr=0 >/dev/null 113225521Shrs ${SYSCTL} net.inet6.ip6.rfc6204w3=0 >/dev/null 114225521Shrs ;; 115225521Shrs *) 116225521Shrs netoptions_init 117225521Shrs echo -n " IPv6 CPE WANIF=${ipv6_cpe_wanif}" 118225521Shrs ${SYSCTL} net.inet6.ip6.no_radr=1 >/dev/null 119225521Shrs ${SYSCTL} net.inet6.ip6.rfc6204w3=1 >/dev/null 120225521Shrs ;; 121225521Shrs esac 122197143Shrs} 123169217Smtm 124197143Shrsload_rc_config $name 125197143Shrsrun_rc_command $1 126