The captive portal is a network security solution that automates the control and management of user access to public and private networks. Captive portals are commonly used for guest access management in open access networks, which are found in hotels, hospitals, airports, restaurants, and corporate networks. When the captive portal is enabled, access to the Internet is restricted unless the user provides personal information such as e-mail, name, and Social Security number, or authentication via a voucher via a web-based registration form completed in a web browser.
OPNsense is a FreeBSD-based firewall and routing platform. It is open source, easy to use, and easy to build. Most of the capabilities in pricey commercial firewalls are provided by OPNsense, plus many more. It provides a vast range of commercial products with the advantages of open and reliable sources. One of the benefits of the OPNsense is that it allows network administrators to configure a Captive Portal easily for providing Internet access to their clients in a secure way.
OPNsense not only allows you to deploy a Captive Portal to provide free Internet access to your guests or employees, but it also protects them from cyber attacks with the help of the Zenarmor plugin's next generation firewall capabilities.
Zenarmor NGFW Plug-in for OPNsense is one of the most popular OPNsense plug-ins and allows you to easily upgrade your firewall to a Next Generation Firewall in seconds. NG Firewalls empower you to combat modern-day cyber attacks that are becoming more sophisticated every day.
Some of the capabilities are layer-7 application/user aware blocking, granular filtering policies, commercial-grade web filtering utilizing cloud-delivered AI-based Threat Intelligence, parental controls, and the industry's best network analytics and reporting.
Zenarmor Free Edition is available at no cost for all OPNsense users.
We will cover the following topics briefly in this Captive Portal Configuration on OPNsense tutorial.
As a best practice, to provide your organization's guest free Internet access you should implement network segmentation in your infrastructure by isolating the guest network from private LAN. And then, you can deploy a captive portal to let the guests access the Internet.
In this tutorial, we will enable and configure a captive portal for a guest network on OPNsense 21.7.2 with at least three network interfaces/zones:
You may set up the Captive Portal on your OPNsense firewall by following the 4 steps easily.
You can create a new interface for the Guest Network by following the instructions given below.
You can configure a DHCP server for the Guest Network by following the instructions given below.
You should define the following rules in the given order after navigating Firewall → Rules
Define a rule to Allow the internal DNS server(s), by following the instructions below.
Option | Value |
---|---|
Action | Pass |
Interface | GUESTNET |
Protocol | TCP/UDP |
Source | GUESTNET net |
Source Port | any |
Destination | GUESTNET address |
Destination Port | DNS (53) |
Category | GuestNet Rules |
Description | Allow DNS |
Figure 7. Allow DNS Rule-1
Define a rule to allow the guest to access the Captive Portal, by following the instructions below.
Option | Value |
---|---|
Action | Pass |
Interface | GUESTNET |
Protocol | TCP |
Source | GUESTNET net |
Source Port | any |
Destination | GUESTNET address |
Destination Port | 8000/10000 |
Category | GuestNet Rules |
Description | Allow Captive Portal Login |
Figure 9. Allow Captive Portal firewall rule on OPNsense-1
Define a rule to block the guest to access the corporate LAN, by following the instructions below.
Option | Value |
---|---|
Action | Block |
Interface | GUESTNET |
Protocol | any |
Source | GUESTNET net |
Source Port | any |
Destination | LAN net |
Category | GuestNet Rules |
Description | Block LAN Access |
Figure 11. Blocking LAN access from GuestNet on OPNsense-1
Define a rule to block the guest to access the Firewall, by following the instructions below.
Option | Value |
---|---|
Action | Block |
Interface | GUESTNET |
Protocol | any |
Source | GUESTNET net |
Source Port | any |
Destination | GUESTNET address |
Category | GuestNet Rules |
Description | Block LAN Access |
Figure 13. Blocking Firewall access from GuestNet on OPNsense-1
Define a rule to allow the guests to access the Internet, by following the instructions below.
Option | Value |
---|---|
Action | Pass |
Interface | GUESTNET |
Protocol | any |
Source | GUESTNET net |
Source Port | any |
Destination | any |
Destination port range | any |
Category | GuestNet Rules |
Description | Allow Guest Network |
Figure 15. Allow Guest Network to access the Internet on OPNsense-1
You may need to reorder the newly created firewall rules for the GUESTNET interface. The rule list should be similar to the figure given below. Then, you must click Apply changes to activate the rules.
Figure 17. Firewall rules for GuestNet on OPNsense
You can create a Captive Portal for the Guest Network by following the instructions given below.
Captive Portal installation on OPNsense is completed and ready to use.
Figure 21. Guest Network Captive Portal is created on OPNsense Firewall
When you connect your device to the guest network and open your favorite browser, you will be redirected to the captive portal splash page similar to figure below. Since we did not configure any authentication method in our example above, you can start to surf by clicking on the Sign in button without any authentication.
Figure 22. OPNsense Captive Portal default Splash Page without any authentication
OPNsense Captive Portal supports a variety of authentication methods, such as local, LDAP. Radius, Vouchers, or multiple of them. It is strongly recommended to use at least one of the authentication methods on Captive Portal. In this tutorial, you can find information about configuring the OPNsense Voucher system in the following section.
If you can access the Internet from the guest network, it means that related firewall rules which allow the GUESTNET to access the Internet and DNS server are working. You may test the blocking rules which deny access to the firewall and LAN from the GUESTNET. To verify these Captive Portal firewall rules, you can run the following command from a device connected to the guest network. If your ping requests are timeout for both firewall and LAN access, your firewall rules are correct and work properly.
ping 172.16.10.1 Pinging 172.16.10.1 with 32 bytes of data: Request timed out. Request timed out. Request timed out.
ping 10.10.10.1 Pinging 10.10.10.1 with 32 bytes of data: Request timed out. Request timed out. Request timed out.
You may also optionally configure the Captive Portal by following the instructions given below.
After configuring captive portal on your OPNsense firewall, you can define user-based filtering on your Zenarmor NGFW to protect your network easily. Zenarmor next-generation firewall plugins enable you to create policies using captive portal usernames and groups. Zenarmor also supports the OPNsense voucher authentication system. And you may define user-defined filtering using vouchers on your OPNsense too.
One of the most powerful features of OPNsense's Captive Portal solution is the template feature, which is also very simple to use.
To make a custom landing page, you may follow the steps given below.
Now you can test your new captive portal template by opening a browser. Splash page should look similar to the page given below.
Figure 29. Customized captive portal login page on OPNsense
Captive portal can be used in conjunction with the traffic shaper to fully utilize its shaping capabilities.
You can limit the Internet bandwidth usage on the guest network by following the steps given below. For this example, we will allow maximum 10 Mbps download and 1 Mbps upload bandwidth for the visitors Internet access. This bandwidth will be shared among all connected guests.
You may add pipes for Download and Upload Bandwidth Limitations by following the next steps given below.
You may follow the instructions given below to create the traffic shaper rules for Download and Upload Bandwidth Limitations on the guest network.
To test the traffic shaping policies to limit the bandwidth on Guest Network, follow the instructions given below.
You may also compare bandwidth speed test results before applying the traffic shaping.
Figure 40. Comparison of speed test results for download(before and after traffic shaping)
Figure 41. Comparison of speed test results for upload(before and after traffic shaping)
OPNsense's Captive Portal provides a simple voucher creation system that is especially useful for Hotel Networks. You may manage your voucher system on the OPNsense firewall by following the steps below.
To add a Voucher Server you can follow the next steps.
To create vouchers for your guest network you can follow the next steps.
A file will be generated called Wi-Fi daily pass.csv .
Vouchers' passwords are not kept on the OPNsense firewall for security reasons.
Field | Description |
---|---|
username | The username that the guest must use to log in |
password | The password that the guest must use to log in |
vouchergroup | The name of the group |
validity | The time the voucher will be valid in seconds |
To enable the voucher authentication on the OPNsense firewall, you may follow the next steps given below.
To check the validity and active status of a voucher, navigate to Services → Captive Portal → Vouchers . And select the correct database, such as Wi-Fi daily pass in our example.
Figure 52. Viewing the Vouchers Status on OPNsense
To check the active sessions navigate to Services → Captive Portal → Sessions on OPNsense Web UI. And then, select the proper zone from the selection box at the upper right corner.
Current session looks like this:
Figure 53. Checking the active captive portal sessions on OPNsense
To drop an active session you may click on the trash icon.
Figure 54. Dropping an active Captive Portal session on OPNsense
OPNsense provides a very powerful CLI that is especially useful for debugging. And, you may also use the CLI to get a list of all active sessions' statuses.
Type the following command on the OPNsense command line to see the active sessions on zone id 0 :
root@OPNsense:~ # configctl captiveportal list_clients 0 sessionid username ip_address mac_address total_bytes idletime totaltime acc_session_timeout ivN8tfSozem614bkXzeZXQ== Q$)49ZHm 172.16.10.100 8c:16:45:6d:76:28 2086815 2 240 86400
The main advantages of the OPNsense Captive Portal are explained below.
The implementation of a captive portal can help you keep your business in accordance with regulatory standards and good practices in providing Internet access to users via hotspots.
A captive portal typically displays terms of service to the user, which they must accept before using the company's Wi-Fi hotspot. Administrators often do this to ensure that their own users take responsibility for their acts and that they are not held legally liable. Property owners can protect themselves from legal liability by requiring their users to agree to a Terms of Service (ToS) page before getting access to the network via a Captive Portal. The Captive Portal operates by "redirecting" any Web request to a specific page until the user clicks I Agree to the Terms of Service. As a result, regardless of what URL your browser asks, the Captive Portal page will appear first when you start a Web browser. The captive portal may, in some situations, need a password. This type of safeguard protects you from legal liability in the event of illegal or otherwise harmful online behavior, while similar security features safeguard company assets.
Some users always misuse Internet services, for instance by remaining online many hours a day, accessing multiple times a day, or even connecting to them over several terminals. And depending on the sort of activity performed on your connection, it might also occupy a bandwidth.
The Captive Portal provides a number of measures for ensuring sufficient access to all users: connection time can be controlled, the number of terminals per user, bandwidth use.
You can regulate your bandwidth using a captive portal and create configurable time limitations as far as each user can stay connected to your network.
Zenarmor allows you to define user-based policies for content filtering and application control. Therefore, you can not only provide your clients free Internet access but also protect them against cyberthreats, such as malwares, phishing, etc.
In commercial terms, captive portals offer an ideal chance for seamless marketing that makes it possible for users to become involved during their internet experience at a vital time and is a powerful medium for a wide variety of business demands. To fill in a survey, watch a sponsored ad or highlight current promotions, you may use a captive portal.
This means that the provider of this service can display or send ads to people connecting to the Wi-Fi connection. This type of service is frequently called "social WiFi" because it can prompt you to log in to a social network account. These social wireless Internet portals have been prevalent over the last several years with several companies offering marketing focusing on Wi-Fi data collection.
OPNsense provides a Captive Portal to force clients who request network access to authenticate or redirect them to a click-through page. This solution is generally used on hotspot networks, but it is also broadly used in enterprise networks to provide an extra layer of security for Internet or wireless access.
OPNsense Captive Portal has the following features.
It is becoming increasingly popular for public and private locations to provide users with free Internet access, delivering convenience, connecting organizations and people, and serving a variety of objectives. However, certain formalities must be observed for providing an Internet connection. Free Internet access should be provided in public and private spaces following a variety of safety standards to minimize the usage of harmful people for illegal activities. Captive Portal is one of the most common security solutions for this problem.
Typical applications of Captive Portal on OPNsense are listed below.
Companies generally offer their visitors internet access and show them a landing page with a welcome message and some guidelines and network access policies. At the same time, it is critical to ensure that visitors cannot access the private LAN and exhaust the Internet bandwidth.
Hotels and RV parks typically use a captive portal to provide guests with limited Internet access. Guests must log in using a voucher that can be purchased or obtained for free at the reception desk. OPNsense includes voucher support and can quickly generate them on the fly.
Hackers today steals information in one of the easiest ways by acting as a lawful wireless network. When one of your clients logs into the fake network, the hacker has a simple way to gather their information. If your company is a coffee shop or a hospital that provides your clients or patients with free Wi-Fi in the waiting area, your network should thus be identified correctly with your end customers so that they do not log in to any potential falsification. OPNsense captive portal is one of the best solutions to protect your customers from being a victim of a cybercrime.