Skip to content
Windows

How to Backup and Restore Microsoft Defender Firewall in Windows 11

Richard
Written by
Richard
Updated 7 min read
How to Backup and Restore Microsoft Defender Firewall in Windows 11
How to Backup and Restore Microsoft Defender Firewall in Windows 11
Before you start
  • 2 ways to do it
  • Needs administrator rights

Backing up and restoring Microsoft Defender Firewall (the built-in Windows tool that blocks unsafe network traffic) saves your custom security rules to a single .wfw file. In Windows 11, you export the rules with a few clicks in the advanced firewall console or with one command in Windows Terminal.

The file saves a lot of work when you reinstall the operating system, set up a new computer, or want a safety net before you change rules. You restore it later with the matching Import Policy option or command.

⚡ Quick Answer

Open Windows Security, go to Firewall & network protection, then Advanced settings, and click Export Policy in the Actions pane to save your firewall rules as a.wfw file. Alternatively, run netsh advfirewall export “📁C:\Backup\firewall.wfw” in Windows Terminal as administrator. Restore the file later with Import Policy or netsh advfirewall import.

Advertisement

Why Back Up Your Firewall Settings?

Backing up your firewall keeps your security settings safe. The backup holds your inbound and outbound rules and the settings for each network profile (Domain, Private and Public). If a bad change, a failed update or a reinstall wipes them out, you can restore them in a minute instead of rebuilding every rule by hand.

Make a fresh backup before you add a batch of new rules, and again after you finish a setup you are happy with. Keep a copy somewhere other than the PC itself, such as a USB drive or cloud storage, so the file survives if the drive fails.

Advertisement

Method 1Using Windows Security App

The Windows Security app is a reliable route to the export option, and it needs no command-line tools. You open the app, go into the advanced firewall console (the older-style window with the full list of rules), and use its built-in Export Policy option to save your current rules to a file. If your settings get reset later, you restore them from that file.

The steps below work the same on Home and Pro editions of a currently supported Windows 11 version (25H2 or 26H2). You need an administrator account, because the advanced console asks for permission before it opens. Follow the steps in order.

  1. Click the Start button (Windows icon), then click Settings. You can also press the Win and I together to open it directly.
Windows 11 Start menu with Settings highlighted
windows 11 start menu settings updated

The Settings window should now be open, with a list of categories down the left side.

  1. Click Privacy & security on the left side, then click Windows Security. It sits near the top of the list on the right, under the Security heading.
Windows Security option in Privacy & security settings
Windows Security option in Privacy & security settings

The Windows Security page should now show on the right, with a button to open the app and a list of protection areas.

  1. Click the Open Windows Security button.
Open Windows Security button
Open Windows Security button

The Windows Security app should now open in its own window, showing a home page with tiles for each protection area.

  1. In the Windows Security app, click Firewall & network protection. You can also open it with this link: Firewall & network protection.
Firewall & network protection section in Windows Security app
Windows 11 Security app showing Firewall and network protection section.

You should now see the firewall page, which lists the Domain, Private and Public network profiles and shows which one is active.

If this page is greyed out or says your settings are managed, your PC is probably controlled by an organization or by third-party security software. In that case you may not be able to change or export the rules from here. Ask your IT administrator, or check the other security product’s own settings, before you go further.

  1. Scroll down and click Advanced settings. If Windows shows a User Account Control prompt, click Yes. If you are signed in as a standard user, Windows asks for an administrator password instead.
Advanced settings link in Windows Security app
Advanced settings link in Windows Security app

A new window called Windows Defender Firewall with Advanced Security (the console title still uses this older name) will open. It has a tree of items on the left, your inbound and outbound rules in the middle and an Actions pane on the right.

There are two quicker ways to reach this console. Press Win+R, type wf.msc and press Enter, or search for Windows Defender Firewall with Advanced Security in Start and open the result. Both skip the Settings pages above and still ask for administrator permission.

  1. In the console, click Export Policy in the Actions pane on the right. If you do not see it, select the top item in the left tree, Windows Defender Firewall with Advanced Security on Local Computer. The Actions pane changes depending on what you have selected.
Export and Import Policy options in Windows Defender Firewall Advanced Security
Export and Import Policy options in Windows Defender Firewall Advanced Security

A Save As dialog should now appear, ready for you to pick a location and a file name.

  1. Choose where to save the file, such as your Desktop.
  2. Type a name for the file, such as FirewallBackup.wfw. Windows saves it as a firewall policy file with the .wfw extension.
  3. Click Save. A short message should confirm that the policy was exported successfully.
  4. Click OK to close the message.
Advertisement

What Happens After You Export?

That’s it. Your firewall settings are now saved in a file. Copy it to a USB drive or cloud storage so you can use it later if you need to. The export does not change anything on your PC, so there is nothing to undo.

How to Restore Your Settings

⚠️WarningTo restore, use the same console you used for the backup. Importing replaces your current rules, so check that you have the right file before you start.
  1. Go back to the Windows Defender Firewall with Advanced Security window (the console title still uses this older name). If you closed it, repeat the steps in Method 1 above to open it again.
  2. Click Import Policy in the Actions pane on the right. A warning appears.
  3. Read the warning. Importing replaces all of your current firewall rules and settings with the ones in the file. Click Yes to continue.
  4. Browse to your saved backup file, select it and click Open. A message should confirm the import.

That’s it. Your firewall settings are restored, and Windows should show a message saying the import was successful. You do not need to restart or sign out. Because an import overwrites what is there now, export your current settings first if you might want to go back.

⚠️WarningIf you end up with a result you do not want, the same Actions pane has a Restore Default Policy option that returns the firewall to its factory settings. This deletes all custom rules, including those added by installed apps, and it is hard to undo. Export your current policy before you click it.

Method 2Using Command Prompt

If you like typing commands, use this method instead. It also suits scripts, remote sessions, or times when the graphical console will not open. The commands need an elevated (administrator) window.

  1. [ADMIN REQUIRED] Open Windows Terminal as administrator. Click Start, type Windows Terminal, right-click it, and choose Run as administrator. Click Yes if Windows asks for permission. The window title should include the word Administrator.
  2. Make sure you are in the Command Prompt or PowerShell tab. Either one works for the commands below. If you opened a different tab type, open a new tab from the drop-down arrow at the top of the window.

To Backup Your Firewall Settings

To back up, type this command and press Enter:

⬛Command Prompt
netsh advfirewall export "%userprofile%\Desktop\FirewallBackup.wfw"

This saves your backup file on your Desktop. The command should print Ok. when it finishes. If you get an access denied error, the window is not running as administrator, so close it and reopen it with Run as administrator. Check that the file is on your Desktop before you rely on it.

To Restore Your Firewall Settings

To restore, type this command and press Enter. Change the path if your file is somewhere else, and keep the path inside the quotation marks if it contains spaces. As with the graphical method, this replaces your current rules with the ones in the file:

⬛Command Prompt
netsh advfirewall import "%userprofile%\Desktop\FirewallBackup.wfw"

You should now have your saved firewall settings back in place. The command prints Ok. when it succeeds, and you do not need to restart or sign out. To confirm, open the advanced firewall console and look through the inbound and outbound rules for the ones you expect.

Summary

If an import leaves the firewall behaving oddly, Restore Default Policy resets it, but it also deletes your custom rules, so import your backup file again afterward. Make a new backup each time you add or change rules, and keep one copy off the PC. A good next task is reviewing which inbound rules you still need, since a clean rule set makes every later backup easier to read.

Have a question about this guide?

Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.

Tags: #Windows 11

Did this guide fix your problem?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked * How we handle comments