Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision 936835e135a18adfccf27258eb51edd1dd5fe962)
+++ uspace/srv/net/il/ip/ip.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
@@ -696,4 +696,6 @@
 			return ip_release_and_return(packet, EAFNOSUPPORT);
 	}
+	netif = NULL;
+	route = NULL;
 	fibril_rwlock_read_lock(&ip_globals.netifs_lock);
 	// device specified?
@@ -704,5 +706,6 @@
 			route = &ip_globals.gateway;
 		}
-	}else{
+	}
+	if(! route){
 		route = ip_find_route(*dest);
 		netif = route ? route->netif : NULL;
@@ -726,5 +729,7 @@
 		}
 	}
-	if(route->address.s_addr == dest->s_addr){
+	// if the local host is the destination
+	if((route->address.s_addr == dest->s_addr)
+		&& (dest->s_addr != IPV4_LOCALHOST_ADDRESS)){
 		// find the loopback device to deliver
 		dest->s_addr = IPV4_LOCALHOST_ADDRESS;
@@ -1581,4 +1586,11 @@
 	fibril_rwlock_read_lock(&ip_globals.lock);
 	route = ip_find_route(*dest);
+	// if the local host is the destination
+	if(route && (route->address.s_addr == dest->s_addr)
+		&& (dest->s_addr != IPV4_LOCALHOST_ADDRESS)){
+		// find the loopback device to deliver
+		dest->s_addr = IPV4_LOCALHOST_ADDRESS;
+		route = ip_find_route(*dest);
+	}
 	if(!(route && route->netif)){
 		fibril_rwlock_read_unlock(&ip_globals.lock);
