Zum Inhalt

OpenWrt - Network Configuration

Firewall, port forwarding, etc.? What and how should this get configured to make our services available?

This article describes exemplary how to make the necessary adjustments to the firewall

All articles of the OpenWrt series

OpenWrt - Overview

OpenWrt - Network Configuration

Interfaces Configuration

OpenWrt universally distinguishes between two types of software network interfaces:

  • Physical devices
  • Virtual Network Interfaces (see ➡️ Switches)

Links:

The OpenWrt setup uses the interfaces as shown in the screenshot.

OpenWrt - Network Configuration


WAN Interface

The WAN interface is the connection between the OpenWrt device (= AVM FRITZ!Box 4040) and the network router (= AVM FRITZ!Box 7490)

The IP address of the OpenWrt device is configured in the router's network settings to 192.168.xxx.xxx.

General Settings

OpenWrt - Network Configuration

The option Masquerading must be checked otherwise the WireGuard interface is not able to use the networks DNS server.

The DNS server is redirected to the local DNS server 127.0.0.1.

The DNS documentation is explained in detail in the manual ➡️ OpenWrt - Stubby & DNSMASQ

Advanced Settings

OpenWrt - Network Configuration

Firewall Settings

OpenWrt - Network Configuration

DHCP Server - General Settings

OpenWrt - Network Configuration

DHCP Server - Advanced Settings

OpenWrt - Network Configuration

IPv6 is not in use in the network.

DHCP Server - IPv6 Settings

OpenWrt - Network Configuration


LAN Interface

OpenWrt - Network Configuration

The IP address of the OpenWrt device is set to a static address which is configured in Interfaces - LAN - General Settings

IP address: 192.168.200.1

The IP range is 192.168.200.1 - 192.168.200.255

The network interface lan is a bridge from one network segment to the other.

The IPv4 gateway is the IP address of the router. (please refer to ➡️ AMV Router Configuration)

General Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

Firewall Settings

OpenWrt - Network Configuration

DHCP Server - General Setup

OpenWrt - Network Configuration

DHCP Server - Advanced Setup

OpenWrt - Network Configuration

DHCP Server - IPv6 Settings

OpenWrt - Network Configuration

DHCP Server - IPv6 RA Settings

OpenWrt - Network Configuration

Services, Tools and Apps

If you need to access special services, tools and apps from your lan you have to open the specific port in your firewall.

In the table below some are listed.

Name Port TCP or UDP Link
http 80 TCP de.wikipedia.org
https 443 TCP de.wikipedia.org
SSH 22 TCP SSH Port, de.wikipedia.org
borgbackup 23 TCP Hetzner Storage Box mit BorgBackup nutzen, Hetzner Hilfe
DNS 53 TCP de.wikipedia.org
DNS 853 TCP de.wikipedia.org
NTP 123 TCP / UDP de.wikipedia.org
smtp 465 TCP Nextcloud Installation, de.wikipedia.org, Strato Hilfe, Google Developer, web.de
imap 993 TCP de.wikipedia.org, Strato Hilfe, Google Developer, web.de
Syncthing 8384 TCP docs.syncthing.net
mosh 60000 - 61000 UDP mosh.org, de.wikipedia.org
CalDav TCP e.g. Synology, mailbox.org, posteo.de
CardDav TCP e.g. Synology, mailbox.org, posteo.de

DMZ Interface

A DMZ is only recommended when a server shall be accessible from the internet.

In this example Nextcloud server is set into DMZ and made accessible from the internet.

The DMZ uses the VLAN configuration. The Device must be set to the respective VLAN.

General Settings

OpenWrt - Network Configuration

The Device should be the VLAN.

Advanced Settings

OpenWrt - Network Configuration

Firewall Settings

OpenWrt - Network Configuration

DHCP Server - General Settings

OpenWrt - Network Configuration

DHCP Server - Advanced Settings

OpenWrt - Network Configuration

IPv6 Settings

OpenWrt - Network Configuration


Wireguard Interface

Please refer to the detailed WireGuard descriptions:


Wireless

The two wireless interfaces are deactivated.

OpenWrt - Network Configuration


Switches

Standard switch configuration of OpenWrt after a fresh OpenWrt installation.

OpenWrt - Network Configuration

A new VLAN is created to make all devices plugged in to LAN 3 of AVM FRITZ!Box 4040 accessible from the internet, in this example a Nextcloud server.

It is important that the CPU port (= WAN port of the AVM FRITZ!Box 4040) is set to tagged. The port to which the device is connected (eth3 in this example) is set to untagged.

Menu: Netzwerk -> Switch

OpenWrt - Network Configuration

  • CPU needs to be set to tagged
  • LAN connection needs to be set to untagged. This is the ethernet port where the device / network is plugged in.

🇬🇧 The purpose of a tagged port is to pass traffic for multiple VLANs, whereas an untagged port accepts traffic for only a single VLAN. Generally speaking, tagged ports will link switches, and untagged ports will link to end devices.

🇩🇪 Der Zweck eines getaggten Ports ist es, Datenverkehr für mehrere VLANs durchzulassen, während ein nicht getaggter Port nur Datenverkehr für ein einziges VLAN akzeptiert. Im Allgemeinen verbinden getaggte Ports Switches und nicht getaggte Ports Endgeräte.


Routing

Static IPv4 Routes

OpenWrt - Network Configuration

Static IPv6 Routes

OpenWrt - Network Configuration

Static IPv4 Rules

OpenWrt - Network Configuration

Static IPv6 Rules

OpenWrt - Network Configuration


DHCP and DNS

The DNS settings are configured for Stubby and DNSMAQS ➡️ OpenWrt - Stubby & DNSMASQ

If you don't have Stubby DNSMAQS installed on your OpenWrt device, keep the default settings.

General Settings

OpenWrt - Network Configuration

Resolv and Host Files

OpenWrt - Network Configuration

PXE/TFTP Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

Static Leases

OpenWrt - Network Configuration

Hostnames

OpenWrt - Network Configuration

IP Sets

OpenWrt - Network Configuration


Firewall - General Settings

The OpenWrt setup uses the Firewall Zones as shown in the screenshot.

OpenWrt - Network Configuration

Firewall - Zone wan

⚠️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️

When input is set to reject it is not possible to access OpenWrt from wan!!!

⚠️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️ 🌩️

General Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

Conntrack Settings

OpenWrt - Network Configuration


Firewall - Zone lan

General Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

Comtrack Settings

OpenWrt - Network Configuration


Firewall - Zone dmz

General Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

Conntrack Settings

OpenWrt - Network Configuration


Firewall - Zone wg

Interface for the WireGuard VPN.

General Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

Conntrack Settings

OpenWrt - Network Configuration


Firewall - Port Forwards

Port forwards are necessary that the device in the DMZ os accessible via defined ports from WAN. (The device is accessible from the internet. Please make sure that the respective ports are open on the router (= AVM FRITZ!Box 7490). ➡️ Portfreigaben

Port Forwards

OpenWrt - Network Configuration

Firewall - Port Forwards nextcloud-80

This rule is only required for the renewal of Let's Encrypt certificate.

Port Forwards 80 - General Settings

OpenWrt - Network Configuration

Port Forwards 80 - Advanced Settings

OpenWrt - Network Configuration


Firewall - Port Forwards nextcloud-443

This rule is only required for the renewal of Let's Encrypt certificate.

Port Forwards 443 - General Settings

OpenWrt - Network Configuration

Port Forwards 443 - Advanced Settings

OpenWrt - Network Configuration

Firewall - Port Forwards nextcloud-20000

This rule makes the share.domain.de device accessible from the internet via port 20.000. When this rule is deactivated the Nextcloud won't be visible in the internet.

General Settings

OpenWrt - Network Configuration

Advanced Settings

OpenWrt - Network Configuration

More Port Forward Rules are configured for DNS. Please refer to ➡️ Hijack DNS for a detailed description.


Firewall - Traffic Rules

The traffic rules are hierarchically organized. The firewall goes from top to bottom. If it finds a match it stops regardless of the successive rules. The following rule will be ignored.

Traffic Rules - Overview

The screenshots show is an example. It shows not all rules described in this section.

OpenWrt - Network Configuration

This block-all-dmz rule shall be the last active rule in your list. If you define new rules place them above this rule.

OpenWrt - Network Configuration

At the bottom all OpenWrt standard rules are listed. The rules are DISABLED.

OpenWrt - Network Configuration


Firewall - Traffic Rules - Allow-Wireguard-Inbound

Allow-Wireguard-Inbound - General Settings

OpenWrt - Network Configuration

Allow-Wireguard-Inbound - Advanced Settings

OpenWrt - Network Configuration

Allow-Wireguard-Inbound - Time Restrictions

OpenWrt - Network Configuration


Firewall - Traffic Rules - dmz-dhcp

Traffic Rules - dmz-dhcp - General Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-dhcp - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-dhcp - Time Restrictions

OpenWrt - Network Configuration


Firewall - Traffic Rules - dmz-dns-53

Traffic Rules - dmz-dns-53 - General Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-dns-53 - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-dns-53 - Time Restrictions

OpenWrt - Network Configuration


Firewall - Traffic Rules - dmz-dns-853

Traffic Rules - dmz-dns-53 - General Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-dns-853 - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-dns-853 - Time Restrictions

OpenWrt - Network Configuration


Firewall - Traffic Rules - dmz-allow-smtp

Traffic Rules - dmz-allow-smtp - General Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-allow-smtp - - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-allow-smtp - Time Restriction

OpenWrt - Network Configuration


Firewall - Traffic Rules - dmz-http-https

This rule allows the Nextcloud server which runs on a Raspberry Pi to communicate with the repositories to update / upgrade installed software packages.

Without this rule the Raspberry Pi isn't able to ter the current lists.

Traffic Rules - dmz-http-https - General Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-http-https - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-http-https - Time Restriction

The rule is time restricted! The devices in dmz can only access the wan is the specified time slot.

OpenWrt - Network Configuration


Firewall - Traffic Rules - dmz-icmp

Traffic Rules - dmz-icmp - General Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-icmp - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - dmz-icmp - Time Restrictions

OpenWrt - Network Configuration


Firewall - Traffic Rules - ssh-from-lan-into-dmz

Traffic Rules - ssh-from-lan-into-dmz - General Settings

OpenWrt - Network Configuration

Traffic Rules - ssh-from-lan-into-dmz - Advanced Settings

OpenWrt - Network Configuration

Traffic Rules - ssh-from-lan-into-dmz - Time Restrictions

OpenWrt - Network Configuration


Firewall - Traffic Rules - block-all-dmz

This is n important rule. It will block all traffic which is not explicitly allowed to pass from dmz to any other network.

Traffic Rules - block-all-dmz - General Settings

OpenWrt - Network Configuration

Traffic Rules - block-all-dmz - General Settings

OpenWrt - Network Configuration

Traffic Rules - block-all-dmz - General Settings

OpenWrt - Network Configuration


Firewall - NAT Rules

OpenWrt - Network Configuration

All articles of the OpenWrt series

Gib mir gerne einen Kaffee ☕ aus ❗️

Wenn dir meine Beiträge gefallen und geholfen haben, dann kannst du mir gerne einen Kaffee ☕️ ausgeben.

Donation via PayPalDonation via LiberaPay

Donation via Bitcoin
Bitcoin Address: bc1qfuz93hw2fhdvfuxf6mlxlk8zdadvnktppkzqzj

Source

Official OpenWrt Logo - https://OpenWrt.org/_media/docs/guide-graphic-designer/OpenWrt-logo-usage-guidelines.pdf