xref: /freebsd/libexec/rc/rc.d/natd (revision 02e9120893770924227138ba49df1edb3896112a)
1#!/bin/sh
2#
3#
4
5# PROVIDE: natd
6# KEYWORD: nostart nojailvnet
7
8. /etc/rc.subr
9. /etc/network.subr
10
11name="natd"
12desc="Network Address Translation daemon"
13rcvar="natd_enable"
14command="/sbin/${name}"
15pidfile="/var/run/${name}.pid"
16start_precmd="natd_precmd"
17required_modules="ipdivert"
18
19natd_precmd()
20{
21	if [ -n "${natd_interface}" ]; then
22		dhcp_list="`list_net_interfaces dhcp`"
23		for ifn in ${dhcp_list}; do
24			case "${natd_interface}" in
25			${ifn})
26				rc_flags="$rc_flags -dynamic"
27				;;
28			esac
29		done
30
31		if echo "${natd_interface}" | \
32		    grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
33			rc_flags="$rc_flags -a ${natd_interface}"
34		else
35			rc_flags="$rc_flags -n ${natd_interface}"
36		fi
37	fi
38
39	return 0
40}
41
42load_rc_config $name
43run_rc_command "$1"
44