diff --git a/lib/backend.py b/lib/backend.py
index e31d1d243ce81fe87d42d232d64f5529dd6e4a81..2fa571364f70c19a700f9d30e22f08071a83efb7 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -278,6 +278,21 @@ def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn):
   return decorator
 
 
+def _BuildMasterIpHookEnv():
+  """Builds environment variables for master IP hooks.
+
+  """
+  cfg = _GetConfig()
+  env = {
+    "MASTER_NETDEV": cfg.GetMasterNetdev(),
+    "MASTER_IP": cfg.GetMasterIP(),
+  }
+
+  return env
+
+
+@RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup",
+               _BuildMasterIpHookEnv)
 def ActivateMasterIp():
   """Activate the IP address of the master daemon.
 
@@ -349,6 +364,8 @@ def StartMasterDaemons(no_voting):
     _Fail(msg)
 
 
+@RunLocalHooks(constants.FAKE_OP_MASTER_TURNDOWN, "master-ip-turndown",
+               _BuildMasterIpHookEnv)
 def DeactivateMasterIp():
   """Deactivate the master IP on this node.
 
diff --git a/lib/constants.py b/lib/constants.py
index 51cb8ee8aeda8223775935abbb2cd842712edf6e..a7b09a34bee2286ef889acd2c2006c75a974ddb2 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -1533,3 +1533,8 @@ BLOCKDEV_DRIVER_MANUAL = "manual"
 HTOOLS = _autoconf.HTOOLS
 # The hail iallocator
 IALLOC_HAIL = "hail"
+
+# Fake opcodes for functions that have hooks attached to them via
+# backend.RunLocalHooks
+FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
+FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"