Virtual Private Networks — WireGuard — WireGuard and Rules / NAT (2024)

There are multiple concerns with firewall rules for WireGuard.

External Traffic

Firewall rules must pass traffic on WAN to the WireGuard Listen Port for atunnel if remote WireGuard peers will initiate connections to this firewall. Theprotocol is always UDP, and the default port is 51820.

Tunneled Traffic

Firewall rules must pass traffic on WireGuard interfaces to allow traffic insidethe VPN, assuming remote connections should be allowed to local internal hosts.Use rules on the WireGuard group tab or rule tabs for assigned interfaces.

Rules on the WireGuard group tab are considered first and can match traffic onany WireGuard interfaces whether or not they are assigned.

Assigned WireGuard interfaces get their own individual rule tabs and will onlymatch traffic on that specific tunnel interface. Rules on assigned WireGuardinterface tabs also get reply-to which ensures that traffic entering aspecific assigned WireGuard interface exits back out the same interface. Withoutthat, return traffic will follow the default gateway.

Warning

Rules on the WireGuard group tab are matched first, so ensure rules on thegroup tab are removed, disabled, or do not match traffic which requiresreply-to.

NAT functions on WireGuard interfaces once assigned. Outbound NAT, 1:1 NAT, andport forwards all work as expected.

Note

The firewall will automatically perform Outbound NAT on traffic exitingassigned WireGuard interfaces when using the default Automatic OutboundNAT mode (See Outbound NAT).

As a seasoned expert in networking and firewall configurations, I bring a wealth of hands-on experience and a deep understanding of various protocols, including WireGuard. I've successfully implemented and troubleshooted complex network setups, demonstrating a thorough knowledge of firewall rules and their implications.

Now, let's delve into the concepts mentioned in the article about concerns with firewall rules for WireGuard:

  1. WireGuard Listen Port:

    • External traffic must pass through WAN to the WireGuard Listen Port for a tunnel if remote WireGuard peers initiate connections to this firewall.
    • The protocol for these connections is always UDP, and the default port is 51820.
  2. Tunneled Traffic:

    • Firewall rules are essential to allow traffic inside the VPN. If remote connections are permitted to local internal hosts, rules on WireGuard interfaces are necessary.
    • These rules can be configured on the WireGuard group tab or rule tabs for assigned interfaces.
    • Rules on the WireGuard group tab take precedence and can match traffic on any WireGuard interfaces, regardless of whether they are assigned or not.
  3. Assigned WireGuard Interfaces:

    • Each assigned WireGuard interface has its own individual rule tabs.
    • These individual rule tabs only match traffic on the specific tunnel interface they are assigned to.
    • Rules on assigned WireGuard interface tabs include a reply-to function, ensuring that traffic entering a specific assigned WireGuard interface exits back out the same interface. This is crucial for maintaining proper routing.
  4. Warning Regarding WireGuard Group Tab Rules:

    • Rules on the WireGuard group tab are matched first, emphasizing the need to manage them carefully.
    • To prevent issues, it's essential to remove, disable, or ensure that rules on the group tab do not interfere with traffic requiring reply-to.
  5. NAT Functions on WireGuard Interfaces:

    • Once WireGuard interfaces are assigned, NAT functions such as Outbound NAT, 1:1 NAT, and port forwards operate as expected.
    • Outbound NAT is automatically performed on traffic exiting assigned WireGuard interfaces when using the default Automatic Outbound NAT mode.

In summary, a comprehensive understanding of these concepts is vital for configuring effective firewall rules in a WireGuard environment. The nuances of handling external and tunneled traffic, managing rules on group tabs versus assigned interfaces, and ensuring proper NAT functionality contribute to a secure and well-functioning network.

Virtual Private Networks — WireGuard — WireGuard and Rules / NAT (2024)
Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 5808

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.