Implementing Microsoft Tunnel for MAM

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 10 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Implementing Microsoft Tunnel for MAM: A Comprehensive Guide

Introduction: Bridging the Gap Between Security and Accessibility

In the modern enterprise environment, the perimeter has dissolved. Employees no longer work exclusively from behind a corporate firewall; they operate from coffee shops, home offices, and transit hubs, often using mobile devices that hold sensitive company data. While Mobile Application Management (MAM) allows organizations to secure corporate data within specific applications without requiring full device enrollment, a significant challenge remains: how do these managed applications access on-premises resources that are not exposed to the public internet?

This is where Microsoft Tunnel for Mobile Application Management (MAM) comes into play. Microsoft Tunnel provides a secure, encrypted gateway that allows applications managed by Intune to access internal corporate resources—such as private web servers, internal APIs, or file shares—without requiring the device to be fully enrolled in a Mobile Device Management (MDM) solution. This capability is particularly critical for organizations supporting "Bring Your Own Device" (BYOD) scenarios, where users want access to work resources but are justifiably hesitant to grant the company full administrative control over their personal phones.

By implementing Microsoft Tunnel for MAM, you provide a path for your mobile apps to reach internal data while maintaining the strict privacy boundaries required for personal devices. This lesson will walk you through the architecture, deployment, configuration, and maintenance of the Microsoft Tunnel solution, ensuring you have the knowledge to deploy this gateway effectively and securely.


Not read yet

Understanding the Architecture of Microsoft Tunnel

To effectively implement Microsoft Tunnel, you must first understand how the components interact. At its core, the Microsoft Tunnel gateway is a Linux-based containerized application that runs on a server within your corporate network. It acts as a secure proxy between your mobile applications and your internal network resources.

The Core Components

  1. The Microsoft Tunnel Gateway: This is the server-side component. It is a Linux machine (typically running on Ubuntu or RHEL) that hosts the Docker-based tunnel gateway. It sits in your internal network and maintains a connection to the Microsoft Intune service.
  2. The Intune Service: This acts as the management plane. You define the configuration profiles in the Intune admin center, which are then pushed to the Gateway server and the mobile clients.
  3. The MAM-Enabled Application: These are the client-side apps, such as Microsoft Edge, Outlook, or custom line-of-business (LOB) apps, that have the Intune App SDK integrated. When the app attempts to reach an internal URL, the SDK intercepts the request and routes it through the Tunnel gateway.

Callout: MDM vs. MAM Tunneling It is important to distinguish between Tunnel for MDM and Tunnel for MAM. Tunnel for MDM requires the device to be enrolled in Intune, allowing the entire device's network traffic (or specific app traffic) to be routed through the gateway. Tunnel for MAM is designed specifically for unmanaged (personal) devices. It creates a secure tunnel only for the specific managed applications, ensuring that personal traffic on the device remains completely private and untouched by the corporate gateway.


Not read yet

Prerequisites for Deployment

Before you begin the technical implementation, you must ensure your environment meets specific requirements. Skipping these will lead to connection failures that are notoriously difficult to debug later.

Infrastructure Requirements

  • Operating System: A supported Linux distribution, primarily Ubuntu 20.04/22.04 LTS or RHEL 8.x/9.x.
  • Networking: The server must have access to the public internet to communicate with Intune, and it must have access to the internal resources you intend to expose.
  • Public IP/DNS: You need a public-facing IP address and a corresponding DNS name (e.g., tunnel.yourcompany.com) that points to your gateway server.
  • SSL/TLS Certificates: You must have a publicly trusted SSL certificate for the gateway's public endpoint. Self-signed certificates are not supported for production deployments.

Intune Configuration Requirements

  • Intune License: You or your organization must have the Microsoft Intune Suite or the standalone Intune add-on licenses.
  • Role-Based Access Control: You need Global Administrator or Intune Administrator permissions to create the Tunnel configuration profiles.

Note: Ensure your firewall rules are configured to allow inbound traffic on port 443 from the internet to your gateway server. Additionally, ensure the gateway server can reach your internal resources on the ports required (e.g., 80, 443, or custom ports for internal APIs).


Not read yet

Step-by-Step Implementation Guide

Implementing Microsoft Tunnel is a multi-stage process involving server preparation, gateway installation, and Intune policy configuration.

Phase 1: Preparing the Gateway Server

Start by provisioning a Linux server. A standard virtual machine with 2 vCPUs and 4GB of RAM is usually sufficient for entry-level deployments, but you should scale based on expected concurrent connection volume.

  1. Update the OS: Ensure all packages are up to date.
  2. Install Docker: Microsoft Tunnel runs inside Docker. Install the community edition of Docker on your server.
  3. Verify Networking: Confirm the server can resolve internal hostnames and reach the specific internal services that mobile apps will need to access.

Phase 2: Installing the Tunnel Gateway

Once the server is ready, you will use the Microsoft-provided installation script to set up the gateway.

  1. Download the mstunnel-setup script from the Microsoft Intune portal.
  2. Run the script with elevated privileges: sudo ./mstunnel-setup.
  3. The script will prompt you for your Intune tenant credentials. Authenticate when prompted.
  4. Follow the prompts to select your network interface and configure the server's public-facing address.
  5. The script will automatically pull the necessary Docker images and configure the gateway service.

Phase 3: Configuring the Intune Admin Center

After the server is live and registered, you must tell Intune how to use it.

  1. Create a Tunnel Configuration: Navigate to Endpoint Security > VPN > Microsoft Tunnel Gateway. Create a new configuration.
  2. Define Site Settings: You must create a "Site" that groups your gateway servers. Assign your server to a site.
  3. Create the MAM Tunnel Profile: Navigate to Apps > App configuration policies. Select "Managed apps" as the platform. Choose the applications you want to enable (e.g., Microsoft Edge).
  4. Configure Connection Settings: In the policy, select "Microsoft Tunnel" as the connection type. Link this to the site you created in step 2.

Tip: When defining the "Server URL" in your configuration, always use the Fully Qualified Domain Name (FQDN) rather than an IP address. This makes it easier to update certificates or migrate to a new server in the future without breaking existing client configurations.


Not read yet

Advanced Configuration and Site Management

A single server is a single point of failure. In a production environment, you should always deploy multiple servers behind a load balancer.

Load Balancing the Tunnel

Microsoft Tunnel supports high availability by allowing you to register multiple servers under the same "Site." You can place these servers behind a standard Layer 4 load balancer (like F5 BIG-IP, Citrix ADC, or an Azure Load Balancer).

  • Load Balancer Configuration: Configure the load balancer to perform health checks on the gateway. The gateway exposes a health check endpoint that you can query to ensure the service is responsive.
  • Persistence: Ensure your load balancer is configured to handle long-lived TCP connections, as the tunnel protocol maintains a persistent state.

Managing Internal DNS

One of the most common hurdles is DNS resolution. When a mobile app tries to reach internal.company.local, it needs to resolve that name to an internal IP.

  • Split-Brain DNS: You can configure the Tunnel gateway to act as a DNS forwarder. In the Intune Tunnel configuration, you can specify DNS suffixes. When the mobile app requests a domain ending in those suffixes, the request is sent through the tunnel to the internal DNS server rather than being resolved by the mobile device's carrier network.

Not read yet

Best Practices for Security and Performance

Securing your tunnel gateway is as critical as securing your primary corporate infrastructure. Because this server has a foot in both the public internet and your private network, it is a high-value target.

1. Hardening the Linux Host

  • Minimal Install: Only install the packages required for the tunnel service and Docker. Remove unnecessary software like compilers, debuggers, or web servers that aren't part of the gateway function.
  • SSH Access: Disable root SSH login and use SSH keys rather than passwords. If possible, restrict SSH access to a specific management subnet or a jump box.
  • Firewalling: Use iptables or ufw to restrict inbound traffic to only port 443 (the tunnel port) and your management port (e.g., 22).

2. Monitoring and Logging

  • Log Forwarding: Use a log aggregator (like Azure Monitor, Splunk, or ELK) to ingest logs from the gateway. Monitoring for authentication failures and unauthorized connection attempts is essential.
  • Health Alerts: Configure alerts in the Intune portal for "Gateway Disconnected" events. If a server goes offline, you need to know immediately to prevent user productivity loss.

3. Certificate Management

  • Renewal Automation: Ensure your SSL certificates are monitored for expiration. Manually updating certificates on multiple gateway servers is error-prone. Use tools like certbot if you are using Let's Encrypt, or integrate your certificate management system with the Linux host.

Warning: Never store production private keys in insecure locations on the server. Ensure that the file permissions for your certificate files are set to 600 or 400 so only the root user can read them.


Not read yet

Comparison of Connectivity Methods

To understand why Microsoft Tunnel is preferred for MAM, it helps to compare it against other common connectivity methods.

Feature Microsoft Tunnel for MAM Per-App VPN (MDM) Always-On VPN
Enrollment Required No Yes Yes
Privacy High (App-specific) Medium (Device-wide) Low (All traffic)
Ease of Setup Moderate Moderate Complex
Platform Support iOS/Android iOS/Android Desktop/Mobile
Resource Access Internal Web/API Full Network Full Network

As shown in the table, Microsoft Tunnel for MAM offers the best balance for BYOD scenarios. It provides the necessary access to corporate data while respecting the user's privacy by not touching their personal app data or internet browsing history.


Troubleshooting Common Pitfalls

Even with a perfect setup, you will eventually encounter issues. Being prepared to troubleshoot is what separates a junior administrator from an expert.

Issue 1: Apps Cannot Reach Internal Resources

  • Check DNS: The most common cause is that the mobile device cannot resolve the internal hostname. Verify that the "DNS Suffixes" are correctly configured in the Intune Tunnel profile.
  • Check Firewall: Use tcpdump or nmap from the gateway server to see if the server itself can reach the internal resource. If the server cannot reach the resource, the mobile app certainly cannot.
  • Check Certificates: If the SSL handshake fails, the app will refuse to connect. Use a tool like openssl s_client -connect <your-tunnel-fqdn>:443 to verify the certificate chain from a client machine.

Issue 2: Gateway Server Shows "Disconnected" in Intune

  • Network Interruption: Check if the server's public IP changed or if the firewall is blocking the outbound connection to the Intune service.
  • Docker Service: Sometimes the Docker daemon crashes or fails to restart after a server reboot. Check the status with systemctl status docker.
  • Time Synchronization: Ensure your server is using NTP. If the server clock drifts significantly from the Intune service clock, authentication tokens will fail, and the gateway will disconnect.

Issue 3: High Latency for Users

  • Geographic Proximity: If your users are in Europe but your gateway is in a US-based datacenter, latency will be high. Consider deploying regional gateway sites.
  • MTU Issues: Sometimes, the Maximum Transmission Unit (MTU) size causes packet fragmentation over the tunnel. You may need to adjust the MTU settings in the gateway configuration to accommodate your specific network environment.

Callout: The Importance of Logging When troubleshooting, the mstunnel log files are your best friend. They are located in /var/log/microsoft/mstunnel/. When opening a support ticket with Microsoft, always include the output of the support script, which can be generated by running mstunnel-support on the gateway server. This script bundles all relevant logs and configuration files, saving hours of back-and-forth communication.


Not read yet

Implementing Security Policies for Tunnel Access

Simply having the tunnel is not enough; you must also define who is allowed to use it. This is handled through Intune's Conditional Access policies.

Integrating with Conditional Access

You should create a Conditional Access policy that requires specific conditions before granting access to the resources behind the tunnel.

  1. User Assignment: Target the policy to the group of users who need access to internal apps.
  2. Cloud Apps: Select the internal resources or the managed applications that utilize the tunnel.
  3. Conditions: You might require "Managed Apps" or "App Protection Policies" to be in place.
  4. Grant Controls: Require a "compliant" device or "approved client app" (MAM-enabled).

By linking the Tunnel usage to Conditional Access, you ensure that even if a user manages to install the managed app, they cannot access the internal data unless their device satisfies your organization's security posture (e.g., the app is up to date, the user has passed Multi-Factor Authentication, etc.).


Not read yet

Best Practices for Ongoing Maintenance

Maintenance is not a one-time event. A secure gateway requires a lifecycle management plan.

1. Patch Management

  • Linux Updates: Set up a schedule to apply security patches to the underlying OS. Use a tool like unattended-upgrades to automatically handle security-critical updates.
  • Gateway Updates: Microsoft frequently releases updates to the Tunnel gateway software. Keep track of the release notes. When an update is available, follow the documented upgrade path to ensure you are running the latest version with the most recent security fixes.

2. Capacity Planning

  • Monitoring Trends: Watch the CPU and memory usage on your gateway servers. As you onboard more users or add more applications, you may find that you need to scale up your VM resources or add more nodes to your site.
  • Session Limits: Be aware of the connection limits for a single gateway instance. While the software is designed to be high-performance, there is a physical limit to the number of concurrent TLS connections a single server can manage before performance degrades.

3. Disaster Recovery

  • Configuration Backups: While the configuration is stored in Intune, keep a record of your server-side configurations (like custom network settings or firewall rules).
  • Site Redundancy: Always have at least two servers in a site. If one server fails, the load balancer should automatically route traffic to the healthy node, and the Intune service will continue to manage the remaining gateway.

Not read yet

Key Takeaways for Implementing Microsoft Tunnel

As you wrap up this module, keep these core principles at the forefront of your deployment strategy:

  1. Privacy First: Microsoft Tunnel for MAM is the premier solution for BYOD environments because it maintains a strict separation between personal and work data, ensuring user privacy while meeting corporate security needs.
  2. Infrastructure Matters: The gateway server is the foundation of your connectivity. Invest time in hardening the Linux host, ensuring robust network connectivity, and implementing a proper high-availability strategy with load balancers.
  3. Complexity is in the Details: Most implementation issues stem from DNS resolution, certificate mismatches, or firewall misconfigurations. Validate these three areas first when troubleshooting.
  4. Security is Integrated: Do not treat the tunnel as an isolated component. Integrate it with your Conditional Access policies to ensure that only authorized users on compliant, protected applications can traverse the gateway.
  5. Lifecycle Management: Treat your gateway servers as production infrastructure. This means having a plan for patching, monitoring, log analysis, and certificate renewal. Neglecting these areas will eventually lead to service disruptions.
  6. Use the Tools: Microsoft provides excellent diagnostic scripts (mstunnel-support). Always use them to gather data before attempting manual deep-dives into logs; they are designed to catch the most common configuration errors automatically.
  7. Scalability: Start with a pilot group to validate your network and application behavior before rolling out to the entire organization. Monitor performance metrics during this phase to determine your long-term scaling requirements.

By following these guidelines, you will be able to implement a robust, secure, and user-friendly mobile connectivity solution that empowers your employees to work from anywhere without compromising your organization's security posture. Remember, the goal is to make the technology "disappear" for the end-user—they should simply open their app and find their work data available, while the heavy lifting of encryption, routing, and policy enforcement happens silently in the background.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.