diff --git a/lib/if2ip.c b/lib/if2ip.c
index 065108efa33cd3f4e834812feaf9110159a98b87..420b6df2c5ffbb0128801ceb14d532c0ac0e9a71 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -56,6 +56,11 @@
 #include <arpa/inet.h>
 #endif
 #include <netinet/in.h>
+
+#ifdef HAVE_SYS_TIME_H
+/* This must be before net/if.h for AIX 3.2 to enjoy life */
+#include <sys/time.h>
+#endif
 #ifdef HAVE_NET_IF_H
 #include <net/if.h>
 #endif
@@ -66,10 +71,6 @@
 #include <netdb.h>
 #endif
 
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
 #ifdef HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
 #endif