diff --git a/configure.in b/configure.in
index f8adb490b15b8eac245bd8ca5f9143369ec2b2d1..331d99689e8b74470724e8d1b35c3a848d9bdfdc 100644
--- a/configure.in
+++ b/configure.in
@@ -58,23 +58,11 @@ fi
 
 AC_ARG_ENABLE(transparent,
      AC_HELP_STRING(--disable-transparent, disable transparent proxy support),
-     [case "${enableval}" in 
+     [case "${enableval}" in
         yes) transparent=true ;;
         no)  transparent=false ;;
         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
       esac], [transparent=true])
-if test x$transparent = xtrue; then
-   AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
-   case $host in
-     *-*-linux* )
-       AC_DEFINE(TRANS_NETFILTER, 1, "Define for transparent netfilter") ;;
-     *-*-openbsd*)
-       AC_DEFINE(TRANS_PF, 1, "Define for transparent pf")
-       AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
-     *-*-*bsd* )
-       AC_DEFINE(TRANS_PF, 1, "Define for transparent pf") ;;
-   esac
-fi
 
 case $host in
    *-*-solaris* )
@@ -379,6 +367,11 @@ dnl These headers are not essential
 
 AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h stddef.h inttypes.h utime.h sys/utime.h sys/mman.h alloca.h)
 
+AC_CHECK_HEADERS(net/if.h, [net_if_found=1], [net_if_found=0])
+AC_CHECK_HEADERS(net/pfvar.h, [net_pfvar_found=1], [net_pfvar_found=0])
+AC_CHECK_HEADERS(linux/netfilter_ipv4, [linux_netfilter_ipv4=1],
+                                       [linux_netfilter_ipv4=0])
+
 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam getpwuid ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem mmap strtok_r)
 
 if test $enable_threads = "yes"; then
@@ -386,6 +379,25 @@ if test $enable_threads = "yes"; then
   AC_CHECK_FUNCS(pthread_create)
 fi
 
+if test x$transparent = xtrue ; then
+   transparent_ok=0
+   if test x$net_if_found = x1 -a x$net_pfvar_found = x1 ; then
+     transparent_ok=1
+   fi
+   if test x$linux_netfilter_ipv4 = x1 ; then
+     transparent_ok=1
+   fi
+   if x$transparent_ok = x1 ; then
+     AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
+     case $host in
+       *-*-openbsd*)
+         AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
+     esac
+   else
+     AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
+   fi
+fi
+
 AC_FUNC_FSEEKO
 
 AC_CHECK_MEMBERS([struct timeval.tv_sec])
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 289538e6f6679e77a67d50bcd3ac57efdbc46f78..62fa699e0080a9bc1a6f43d1cd826afa815df9e1 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -13,6 +13,17 @@ const char connection_edge_c_id[] =
 
 #include "or.h"
 
+#ifdef HAVE_LINUX_NETFILTER_IPV4_H
+#include <linux/netfilter_ipv4.h>
+#define TRANS_NETFILTER
+#endif
+
+#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
+#include <net/if.h>
+#include <net/pfvar.h>
+#define TRANS_PF
+#endif
+
 /* List of exit_redirect_t */
 static smartlist_t *redirect_exit_list = NULL;
 
diff --git a/src/or/or.h b/src/or/or.h
index 24701301fb38a70d70c8e39eba597eb3c5946efd..a984819cfb915805a49cfbb71baa435adacf0869 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -113,15 +113,6 @@
 #error "Tor requires libevent to build."
 #endif
 
-#ifdef TRANS_NETFILTER
-#include <linux/netfilter_ipv4.h>
-#endif
-
-#ifdef TRANS_PF
-#include <net/if.h>
-#include <net/pfvar.h>
-#endif
-
 #include "../common/crypto.h"
 #include "../common/tortls.h"
 #include "../common/log.h"