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