diff --git a/src/api/sockets.c b/src/api/sockets.c
index 53c58ea4..3b246d3e 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -3856,6 +3856,52 @@ lwip_ioctl(int s, long cmd, void *argp)
       done_socket(sock);
       return 0;
 
+    case (long)SIOCGIFNAME:
+    case (long)SIOCGIFINDEX:
+    case (long)SIOCGIFADDR: {
+      struct ifreq *ifr;
+      struct netif *netif;
+      ifr = (struct ifreq *)argp;
+      if (!argp) {
+        sock_set_errno(sock, EINVAL);
+        done_socket(sock);
+        return -1;
+      }
+      netif = (cmd == (long)SIOCGIFNAME)
+          ? netif_get_by_index(ifr->ifr_ifindex)
+          : netif_find(ifr->ifr_name);
+      if (!netif) {
+        sock_set_errno(sock, ENODEV);
+        done_socket(sock);
+        return -1;
+      }
+      switch(cmd) {
+        case (long)SIOCGIFNAME:
+          snprintf(ifr->ifr_name, IFNAMSIZ - 1, "%s%d", netif->name, netif->num);
+          LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, SIOCGIFNAME, %d) = \"%s\"\n",
+              s, ifr->ifr_ifindex, ifr->ifr_name));
+          break;
+        case (long)SIOCGIFINDEX:
+          ifr->ifr_ifindex = netif->num;
+          LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, SIOCGIFINDEX, \"%s\") = %d\n",
+              s, ifr->ifr_name, ifr->ifr_ifindex));
+          break;
+        case (long)SIOCGIFADDR: {
+          const struct ip4_addr *addr = netif_ip4_addr(netif);
+          IP4ADDR_PORT_TO_SOCKADDR((struct sockaddr_in *)&ifr->ifr_addr, addr, 0);
+          LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, SIOCGIFADDR, \"%s\") = %d.%d.%d.%d\n",
+              s, ifr->ifr_name, ip4_addr1(addr), ip4_addr2(addr),
+              ip4_addr3(addr), ip4_addr4(addr)));
+          break;
+        }
+        default:
+          break;
+      }
+      sock_set_errno(sock, 0);
+      done_socket(sock);
+      return 0;
+    }
+
     default:
       break;
   } /* switch (cmd) */
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
index b6f3d524..61be8047 100644
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -191,6 +191,10 @@ will need to increase long long */
 #define IFNAMSIZ NETIF_NAMESIZE
 struct ifreq {
   char ifr_name[IFNAMSIZ]; /* Interface name */
+  union {
+    struct sockaddr ifr_addr;
+    int             ifr_ifindex;
+  };
 };
 
 /* Socket protocol types (TCP/UDP/RAW) */
@@ -430,6 +434,17 @@ typedef struct ipv6_mreq {
 #define FIONBIO     _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
 #endif
 
+/* Netdevice Controls: */
+#ifndef SIOCGIFNAME
+#define SIOCGIFNAME _IOW('n', 0, struct ifreq)
+#endif
+#ifndef SIOCGIFINDEX
+#define SIOCGIFINDEX _IOW('n', 1, struct ifreq)
+#endif
+#ifndef SIOCGIFADDR
+#define SIOCGIFADDR _IOW('n', 2, struct ifreq)
+#endif
+
 /* Socket I/O Controls: unimplemented */
 #ifndef SIOCSHIWAT
 #define SIOCSHIWAT  _IOW('s',  0, unsigned long)  /* set high watermark */
diff --git a/test/unit/api/test_sockets.c b/test/unit/api/test_sockets.c
index 3faa5ff9..7192517b 100644
--- a/test/unit/api/test_sockets.c
+++ b/test/unit/api/test_sockets.c
@@ -202,6 +202,34 @@ static void test_sockets_allfunctions_basic_domain(int domain)
   fail_unless(ret == 0);
 }
 
+static void test_sockets_allfunctions_basic_netdev_ioctl(int domain) {
+  int s, ret;
+  struct ifreq ifr;
+  s = lwip_socket(domain, SOCK_STREAM, 0);
+  fail_unless(s >= 0);
+  memset(&ifr, 0, sizeof(ifr));
+
+  ifr.ifr_ifindex = 1;
+  ret = lwip_ioctl(s, SIOCGIFNAME, &ifr);
+  fail_unless(ret == 0);
+  fail_unless(!strncmp(ifr.ifr_name, "lo0", IFNAMSIZ));
+
+  ifr.ifr_ifindex = -1;
+  ret = lwip_ioctl(s, SIOCGIFINDEX, &ifr);
+  fail_unless(ret == 0);
+  fail_unless(ifr.ifr_ifindex == 0);
+
+  ifr.ifr_addr.sa_family = -1;
+  ((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr.s_addr = 0;
+  ret = lwip_ioctl(s, SIOCGIFADDR, &ifr);
+  fail_unless(ret == 0);
+  fail_unless(ifr.ifr_addr.sa_family == AF_INET);
+  fail_unless(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr.s_addr == 0x0100007f);
+
+  ret = lwip_close(s);
+  fail_unless(ret == 0);
+}
+
 /* Try to step through all sockets functions once...
  */
 START_TEST(test_sockets_allfunctions_basic)
@@ -209,9 +237,11 @@ START_TEST(test_sockets_allfunctions_basic)
   LWIP_UNUSED_ARG(_i);
 #if LWIP_IPV4
   test_sockets_allfunctions_basic_domain(AF_INET);
+  test_sockets_allfunctions_basic_netdev_ioctl(AF_INET);
 #endif
 #if LWIP_IPV6
   test_sockets_allfunctions_basic_domain(AF_INET6);
+  test_sockets_allfunctions_basic_netdev_ioctl(AF_INET6);
 #endif
 }
 END_TEST
