diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h
index 0adbd26..ee867af 100644
--- a/openbsc/include/openbsc/bsc_msc.h
+++ b/openbsc/include/openbsc/bsc_msc.h
@@ -22,6 +22,10 @@
 #ifndef BSC_MSC_H
 #define BSC_MSC_H
 
+#ifdef __FreeBSD__
+#include <netinet/in.h>
+#endif
+
 #include <osmocom/core/write_queue.h>
 #include <osmocom/core/timer.h>
 
diff --git a/openbsc/src/ipaccess/ipaccess-find.c b/openbsc/src/ipaccess/ipaccess-find.c
index bb9819e..c8de157 100644
--- a/openbsc/src/ipaccess/ipaccess-find.c
+++ b/openbsc/src/ipaccess/ipaccess-find.c
@@ -41,8 +41,13 @@ static int udp_sock(const char *ifname)
 		return fd;
 
 	if (ifname) {
+#ifdef __FreeBSD__
+		rc = setsockopt(fd, SOL_SOCKET, IP_RECVIF, ifname,
+				strlen(ifname));
+#else
 		rc = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, ifname,
 				strlen(ifname));
+#endif
 		if (rc < 0)
 			goto err;
 	}
