diff --git a/grub2/commands/i386/pc/pxecmd.c b/grub2/commands/i386/pc/pxecmd.c
index df53870..066d9a0 100644
--- a/grub2/commands/i386/pc/pxecmd.c
+++ b/grub2/commands/i386/pc/pxecmd.c
@@ -22,12 +22,14 @@
 #include <grub/misc.h>
 #include <grub/machine/pxe.h>
 #include <grub/extcmd.h>
+#include <grub/env.h>
 
 static const struct grub_arg_option options[] =
 {
     {"info", 'i', 0, "show PXE information.", 0, 0},
     {"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT},
     {"unload", 'u', 0, "unload PXE stack.", 0, 0},
+    {"set", 's', 0, "set network variables PXE_IP etc.", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -43,6 +45,15 @@ print_ip (grub_uint32_t ip)
     }
   grub_printf ("%d", ip);
 }
+static void
+set_ip2env_var(char *var_name, grub_uint32_t ip)
+{
+	char s[20];
+	grub_sprintf (s,"%d.%d.%d.%d", (ip>>0)&0xFF,
+		(ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
+	grub_env_set (var_name, s);
+}
+
 
 static grub_err_t
 grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
@@ -78,6 +89,13 @@ grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
       grub_printf ("\n");
     }
 
+  if (state[3].set)
+    {
+		set_ip2env_var ("pxe_your_ip", grub_pxe_your_ip);
+		set_ip2env_var ("pxe_server_ip", grub_pxe_server_ip);
+		set_ip2env_var ("pxe_gateway_ip", grub_pxe_gateway_ip);
+	}
+
   if (state[2].set)
     grub_pxe_unload ();
 
@@ -89,7 +107,7 @@ static grub_extcmd_t cmd;
 GRUB_MOD_INIT(pxecmd)
 {
   cmd = grub_register_extcmd ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
-			      "pxe [-i|-b|-u]",
+			      "pxe [-i|-b|-u|-s']",
 			      "Command to control the PXE device.", options);
 }
 
