This is a third level spell. It’s weird to let it negate Anti-Magic Field and other magical methods of preventing access. Methods like Anti-Magic Field which also prevent spellcasting are particularly weird since you can teleport in since the spell specifically bypasses obstacles like that, but you then can’t cast the spell to get out because the spell’s cheat-y bypass effect doesn’t kick in until it’s cast. You might not even be able to use the bonus action for other nails you have active, since such a field suppresses magic while you are there, further highlighting the spell’s offensive bias as opposed to your stated defensive intent.
Since the range, like for sending et. al., is self, and the only limitation on where the nail goes is ‘a stationary surface’, this seems to let you effectively cast a super-extra-good transportation version of Plane Shift as a 3rd level spell. For example, you could cast the spell while on the material plane to put the nail in your heavily fortified citadel on the Astral, then again to put one in the floorboards of Mordenkainen’s extradimensional mansion, then warp to the mansion, steal something, and warp to your citadel, all without traveling to either location at any point prior to the spell.
This also bypasses the main limitation you seem to think exists contra misty step— namely that this spell requires set-up time. It doesn’t; you can merely reduce the action cost from one action + one bonus action to one bonus action if you take set-up time. Even without set-up time, this spell can still teleport you to safety without any chance of failure within a single turn.
If you want the spell to be more reasonable and only let you hammer a nail in to a surface you are at, you need to say that. For example, limit the spell to nailing “a solid surface within 5′ you can see”, or change the spell’s range to 5′ and have it target the surface, which will also make you able to teleport out of but not into anti-teleportation zones, instead of the reverse.
This spell is so good, I would expect every Eldritch Knight and Arcane Trickster, at the very least, to always take it as their first 3rd level spell without fail. On that basis I think it is overpowered.
Comparison with Misty Step:
This spell can be used in a similar manner as Misty Step–as a means of escaping a sticky situation, though it is primarily useful for getting into places. The escape potential for this spell is much greater, as it can only be blocked by preventing the caster from uttering the command word, whereas Misty Step can only teleport a character to a location the caster can see with an at-most-1-mile (via the Lore Wizard specialization) range.
Misty Step can be cast reactively and requires a bonus action, whereas this spell requires an action and bonus action except when time was taken to prepare within a minute of the combat (or an hour for the 5th level version). Since we are looking at escaping a combat, this is functionally the same action cost– neither spell takes longer than the user’s turn to escape, although Misty Step has a very slight advantage in the caster being able to take an action, rather than merely a free object interaction, to prepare before the teleportation.
This spell requires a spell slot of 3rd level or higher, while Misty Step requires only a 2nd level spell slot, which is a significant balancing factor, but this spell is nearly always better than Misty Step in every situation, even those Misty Step is most specialized at, despite having a completely different niche of its own as well. It beats out Misty Step— one of the best second-level spells in the game– almost as an afterthought to its main function, and that is reason to worry.
Comparison with Teleportation Circle:
Teleportation Circle can be used to access any existing Circle, whereas Dimensional Anchor can be used to access literally any solid surface anywhere the user wishes with no prior notice and nothing those at the destination can do to prevent entry. As such, Teleportation Circle has much, much lower travel utility– the only benefits to that spell are that you can bring along schmucks who didn’t take this one, and that if you take an entire year of set-up time, you can get a permanent effect that doesn’t cost a spell-slot.
Dimensional Anchor doesn’t beat out the (2 spell levels higher) Teleportation Circle spell in its niche– i.e. transporting the party’s non-spellcasters to new adventure locations and setting up interplanetary trade– but it beats it out for every usage outside of that area.
Comparison with Word of Recall:
This spell only works for a single creature (the caster) and has a finite duration, and doesn’t require you to have ever been at the location you want to teleport to, or even know very much about it. The only thing Word of Recall has going for it, like Teleportation Circle, is the mass-transportation usage.