Integrate VMware ESXi to Samba4 Domain
Yes, you can integrate VMware ESXi hosts into a Samba4 Active Directory domain, but ESXi does not natively support Samba4’s SMB-based authentication. Instead, you use ESXi’s Active Directory join feature with the Samba4 domain controller, which provides LDAP and Kerberos services compatible with standard AD clients. This article explains the exact steps, prerequisites, and common pitfalls to get your ESXi hosts authenticating against a Samba4 domain.
Background: ESXi and Samba4 AD Compatibility
VMware ESXi (version 6.x and later) can join an Active Directory domain using its built-in Active Directory integration feature. This works with any domain controller that offers LDAP (port 389) and Kerberos (port 88) services. Samba4, when configured as an AD domain controller, implements these protocols natively—it is not just a file server. Therefore, ESXi sees Samba4 as a standard AD domain controller.
The key difference from joining a Windows Server domain is that Samba4 does not provide some Microsoft-specific extensions. For example, group policy objects (GPOs) are not applied to ESXi hosts, and you must manually configure the krb5.conf file on ESXi if your Samba4 domain uses a realm different from the NetBIOS name. Most environments use the same name for both, so this is rarely an issue.
Prerequisites for the Integration
Before you start, ensure the following are in place:
- A Samba4 domain controller running with the AD role (not just NT4-style domain). Check with
samba-tool domain level show—it should return 2008 or higher. - DNS resolution: ESXi must resolve the domain name and the domain controller’s hostname via DNS. Samba4 usually provides its own DNS server (bind or internal).
- Time synchronization: Kerberos requires the ESXi host’s clock to be within 5 minutes of the domain controller’s clock. Use NTP on both.
- An account with permission to join computers to the domain. By default, any authenticated user can join up to 10 machines, but it’s cleaner to use a dedicated service account.
- ESXi version 6.0 or later for best compatibility; older versions may require additional patches.
Step-by-Step: Joining ESXi to Samba4
The process is done through the vSphere Client (HTML5 or desktop) or via the ESXi command line. Here are the steps using the vSphere Client:
- Log in to the vSphere Client and select the ESXi host.
- Go to Configure → Security & Users → Authentication Services.
- Click Join Domain.
- Enter the domain name (e.g.,
example.local), the username and password of an account with domain join rights. - Optionally, check the box to use the host’s fully qualified domain name (FQDN).
- Click OK. The host will attempt to contact the domain controller via LDAP and Kerberos.
If the join succeeds, the host shows as Domain: example.local. If it fails, check the following:
- DNS: From the ESXi shell, run
nslookup example.localandnslookup dc01.example.local. - Firewall: Ensure ports 88 (Kerberos), 389 (LDAP), 445 (SMB for some operations), and 53 (DNS) are open between ESXi and the Samba4 DC.
- Time skew: Run
dateon ESXi and compare with the DC.
Configuring ESXi for Samba4 Realm Differences
If your Samba4 domain uses a realm that differs from the NetBIOS name (e.g., NetBIOS name is SAMBA but realm is example.local), you must edit the /etc/krb5.conf file on the ESXi host. This is done via the ESXi shell (SSH must be enabled).
- Enable SSH on the host (Host → Configure → Services → TSM-SSH → Start).
- Connect via SSH and edit
/etc/krb5.conf. - Add a
[realms]section mapping the realm to the KDC (the Samba4 DC). - Save and restart the authentication service:
/etc/init.d/authentication-service restart.
In most setups, the default configuration works because Samba4 sets the realm equal to the domain name in uppercase. But if you have a split DNS or a custom realm, this step is essential.
Common Problems and Their Fixes
Here are the typical issues you might encounter and how to resolve them:
- “Cannot join domain: invalid credentials” – Check that the password is correct and that the account is not locked. Also, Samba4 may reject the join if the machine account already exists with a different SID. Delete it with
samba-tool computer delete. - DNS resolution fails – ESXi’s DNS settings may point to an external resolver that doesn’t know your Samba4 domain. Set the ESXi host’s DNS to the Samba4 DC’s IP address.
- Time skew errors – Kerberos is strict about time. Configure NTP on ESXi: Host → Configure → System → Time Configuration → Edit → Use NTP.
- Join succeeds but login fails – This often happens when the ESXi host cannot resolve the domain controller’s Kerberos service. Verify that the DC’s A record exists and that the host’s
/etc/hostsfile does not have a conflicting entry. - Machine account not created – Samba4 may require the user to have the “Create Computer Objects” permission in the specific OU. By default, the “Domain Users” group has this right, but if you’ve restricted it, grant it to the service account.
Comparison: Samba4 vs. Windows Server for ESXi
Functionally, ESXi treats both the same for authentication. However, there are differences:
- Group policy – Windows Server can apply GPOs to ESXi if you use VMware’s GPO extensions, but Samba4 does not support that. You must manage ESXi settings manually or via scripts.
- Kerberos support – Both support Kerberos, but Samba4’s implementation may have minor quirks with certain encryption types. ESXi 6.5+ uses AES-256, which Samba4 supports if compiled with the right libraries.
- Cost – Samba4 is free, while Windows Server requires licensing. For small environments, Samba4 is a viable alternative.
- Management – Windows Server provides the AD Users and Computers MMC; Samba4 uses
samba-toolor the Samba Web Administration Tool (SWAT). Both are functional, but Windows is more familiar to many admins.
Security Considerations and Best Practices
When integrating ESXi with Samba4, keep these security points in mind:
- Use a dedicated service account with minimal privileges—do not use the Domain Administrator account for the join process.
- Restrict which users can log into the ESXi host via the domain. By default, all domain users can log in once the host is joined. You should configure the
ESX Adminsgroup in the Samba4 domain and add only necessary users. - Enable LDAPS (port 636) on Samba4 if you want encrypted LDAP traffic. ESXi supports LDAPS, but you must import the CA certificate to the host.
- Regularly rotate the machine account password. ESXi does this automatically if you leave the default settings, but verify that the Samba4 DC allows password changes.
- Back up your Samba4 configuration and database before making major changes.
Frequently Asked Questions
Can I join ESXi to Samba4 without a Windows machine?
Yes, you can join ESXi directly to Samba4 using the vSphere Client or the ESXi command line. You need Samba4 running as an AD DC, and you must provide credentials that have permission to create computer objects in the domain. No Windows server is required.
Does ESXi support Samba4’s SMB file sharing?
No, ESXi does not use SMB for its own file systems. It uses VMFS and NFS for storage. Samba4’s SMB feature is irrelevant to ESXi integration; only its AD services (LDAP, Kerberos, DNS) matter.
What if my Samba4 domain uses a different DNS suffix than the NetBIOS name?
You must configure the ESXi host’s DNS to resolve the domain’s DNS suffix correctly, and you may need to edit /etc/krb5.conf to specify the realm and KDC. This is uncommon but doable.
Can I use Samba4 to manage ESXi permissions?
Yes, once the host is joined, you can assign domain users and groups to ESXi roles (e.g., Administrator, ReadOnly) via the vSphere Client. You must create the groups in Samba4 and then map them in ESXi’s permissions.
Is there a way to test the integration without affecting production?
You can set up a test Samba4 DC in a lab environment and join a test ESXi host to it. This is the safest way to verify compatibility and configuration before rolling out to production.
What are the limitations of using Samba4 instead of Windows Server for ESXi?
The main limitations are lack of GPO support, no native integration with Microsoft’s management tools, and potentially different behavior in complex multi-site setups. For basic authentication and authorization, Samba4 works well.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.