diff --git a/mojitos.c b/mojitos.c
index d8a888c6267e424d5ceff477c31f0b8e1750889b..0e66a83f57795c39ce99fc00aa6429f506f82160 100644
--- a/mojitos.c
+++ b/mojitos.c
@@ -95,7 +95,7 @@ void usage(char** argv) {
   printf("-p activates performance counters\n");
   printf("   perf_list is coma separated list of performance counters without space. Ex: instructions,cache_misses\n");
   printf("-l lists the possible performance counters and quits\n");
-  printf("-d activates network monitoring\n");
+  printf("-d activates network monitoring (if network_device is X tries to detect it automatically)\n");
   printf("-s activates statistics of overhead in nanoseconds\n");
   printf("-u activates report of system load\n");
   exit(EXIT_SUCCESS);
diff --git a/network.c b/network.c
index 7dfd18badbd59022e6fb466bd00ab3f6223e6b3f..0c03cb5f99f3a67cf0a79fa002e6010316e5adc6 100644
--- a/network.c
+++ b/network.c
@@ -20,10 +20,22 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 char **init_network(char* dev) {
   if(dev==NULL)
     return NULL;
+
+  if(strcmp(dev,"X")==0) {
+    FILE* f = fopen("/proc/net/route", "r");
+    char buffer[1000];
+    fgets(buffer, 999, f);
+    fgets(buffer, 999, f);
+    char *end_of_dev = index(buffer, '\t');
+    *end_of_dev='\0';
+    dev = buffer;
+  }
+  
   char *filenames[] = {"/sys/class/net/%s/statistics/rx_packets",
 		       "/sys/class/net/%s/statistics/rx_bytes",
 		       "/sys/class/net/%s/statistics/tx_packets",