Skip to content
AdminKit

Is port 2049 (NFS) exposed to the internet?

Port 2049 is the registered port for NFS, the Network File System that Linux and Unix servers and many NAS devices use to share directories. With its default AUTH_SYS security, the server trusts the client to say who the user is. AdminKit's port check does not test 2049, so this guide shows how to test and restrict it.

By AdminKit team, Netbase JSC · Updated

Key takeaways

  • Port 2049 carries NFS, the file-sharing protocol of Linux and Unix servers and many NAS devices. NFS version 4 needs only this one port.
  • NFS’s default security flavor, AUTH_SYS, takes the user’s identity from numbers the client sends. Anyone who can reach the server can claim to be any user except root.
  • An export to * in /etc/exports matches every client in the world. Combined with an open 2049, that publishes the directory.
  • AdminKit’s port check does not test 2049. Test it manually from outside your network, then restrict the exports and the port.

What runs on port 2049?

NFS lets a client mount a directory from a server and use it like a local disk. RFC 7530, the NFS version 4 specification, says in §3.1 that NFS version 2 and 3 servers have historically resided on port 2049, and that the registered port 2049 for NFS should be the default configuration. Using it, the RFC explains, means the client does not need the RPC binding protocols, which “will allow NFS to transit firewalls.” RFC 8881, for NFS version 4.1, repeats the default in §2.9.3.

The older versions need more than one port. The nfs(5) man page explains that NFS servers normally run rpcbind on the well-known port 111 to tell clients where each RPC service is, and that while NFS itself often uses 2049, auxiliary services such as the lock manager can pick any unused port at random. The Debian wiki’s NFS server page sums up the difference: NFS version 4 requires only a single port, TCP or UDP 2049, and does not need the portmap service.

PortServiceNeeded by
2049 (TCP, sometimes UDP)NFS itselfEvery NFS version
111 (TCP and UDP)rpcbind / portmapperNFS version 2 and 3 clients, and tools such as showmount
Dynamic, or pinned by the adminmountd, lock manager (NLM), status (statd)NFS version 2 and 3

Linux servers, NAS appliances from home units to enterprise filers, and cloud file services all speak NFS. Many NAS devices enable it next to SMB with a single checkbox.

Why is an exposed NFS server a risk?

Because the server believes what the client says about the user. The nfs(5) man page describes the traditional default, AUTH_SYS: the client sends local UID and GID numbers to identify the user, and the server assumes that if a connection comes from a privileged port, those numbers were verified by the client’s kernel. The man page’s own verdict is that this “is an easy system to spoof, but on a trusted physical network between trusted hosts, it is entirely adequate.”

The internet is neither. Anyone who controls a machine has root on it, can open a privileged port, and can send any UID and GID they like. RFC 7530 §3.2 makes the stronger mechanism mandatory to implement: NFS version 4 clients and servers must support Kerberos V5 through RPCSEC_GSS. Deploying it is optional, though, and the exports(5) man page lists sys, “no cryptographic security”, as the default security flavor of a Linux export.

The data is also unprotected in transit. The nfs(5) security section notes that file data and user ID values typically appear unencrypted on the network, and that the NFS version 2 and 3 sideband protocols for mounting, locking and status use no authentication.

What does root_squash protect, and what doesn’t it?

Linux does block the most obvious attack. exports(5) explains that requests from UID 0 on the client are normally mapped to an anonymous user, a behaviour called root squashing, which is the default and can be turned off with no_root_squash. So a remote root user cannot simply act as root on the share.

The same man page sets out the limit: root_squash maps only UID and GID 0, and “does not apply to any other uids or gids that might be equally sensitive.” A client that claims UID 1000 is user 1000 on the export. If the export holds home directories, deployment keys or backups, every non-root owner of those files can be impersonated.

Some common settings widen the gap further:

Export optionWhat it doesRisk when 2049 is public
* as the clientMatches all clients, per exports(5)Anyone can mount the export
no_root_squashClient root is root on the shareRemote root can write files as root, including setuid binaries
insecureAccepts requests from non-privileged source portsAny user on any client can forge identities, not only root
rwRead-write accessForged identities can change or delete data
sec=sys (the default)No cryptographic authenticationIdentities are whatever the client claims

The Ubuntu Server NFS documentation warns about the first two directly. It tells administrators to make the hostname declaration as specific as possible so unwanted systems cannot access the mount, and says that no_root_squash in a multi-user environment where executables are allowed on a shared mount point “could lead to security problems.”

How do you check your own exposure?

AdminKit’s open ports check tests nine TCP ports on the public IP you connect from, and 2049 is not on that list. Confirm your public address with what is my IP, then test from a machine outside your network. The address below is from the documentation range; use your own:

nc -vz -w 3 203.0.113.5 2049
nc -vz -w 3 203.0.113.5 111
showmount -e 203.0.113.5

The showmount(8) man page explains that showmount queries the mount daemon on a remote host, and that -e shows the server’s export list. It depends on rpcbind and mountd, so it works against servers that offer NFS version 2 or 3.

ResultWhat it means
Connection refused or timeout on both portsNothing answered from where you tested. Check the router’s port forwards and the NAS settings anyway.
2049 answers, 111 does notAn NFS version 4 server is reachable. Exports are not listed, but a client can still try to mount them.
showmount -e prints an export listrpcbind and mountd answer the internet, and the list names each directory and the clients allowed to mount it.
An export listed with * as its clientAny address may mount it. Treat this as an incident.

Only test servers you own or are authorized to test.

How do you confirm the settings on the server?

On a Linux server, list the listeners and the effective exports:

sudo ss -ltnp 'sport = :2049'; sudo ss -ltnp 'sport = :111'
sudo exportfs -v
cat /proc/fs/nfsd/versions

exportfs -v prints each export with its client specification and every option, including defaults, so look for *, broad network ranges, no_root_squash, insecure and sec=sys. /proc/fs/nfsd/versions shows which protocol versions the server offers; the Debian wiki uses it to confirm that versions 2 and 3 are disabled, shown as -2 -3 +4 +4.1 +4.2.

The Debian wiki also documents where the listening address is set. By default NFS listens on all addresses; the -H option to rpc.nfsd, set through RPCNFSDOPTS, restricts it to one address, such as the server’s LAN interface. On a NAS, the equivalent settings are usually in the NFS service page and in per-share NFS rules.

How do you fix an exposed NFS server?

  • Take 2049 and 111 off the internet. Remove router port forwards and cloud security group rules that allow them from any address. Remote users should reach file shares over a VPN.
  • Name the clients. Replace * and wide ranges in /etc/exports with specific hosts or the smallest subnet that needs access, then apply the change with exportfs -ra.
  • Keep the safe defaults. Leave root_squash and secure on, and use ro for anything clients only need to read. Use all_squash for shares that should not map individual users at all.
  • Use NFS version 4 only where you can. It needs only port 2049, and the Debian wiki shows how to disable versions 2 and 3 and mask rpcbind so port 111 is not needed.
  • Use Kerberos where identities matter. exports(5) lists krb5, krb5i and krb5p; the nfs(5) man page explains that krb5p encrypts every request. The Ubuntu documentation walks through NFS with Kerberos.
  • Encrypt the transport if Kerberos is not an option. exports(5) documents RPC-with-TLS and the xprtsec= export option, which can restrict an export to clients that negotiated TLS or mutual TLS. Without that option, an export allows clients with or without TLS.

If the port was open with a permissive export, check the files on that export for changes you did not make, and treat any credentials stored there as exposed.

Does the same question apply to other file-sharing ports?

Yes. Windows file sharing on port 445 (SMB) has the same rule: a LAN protocol with its own login step that should be reached through a VPN, not forwarded from the internet. Many NAS devices run SMB and NFS side by side, so check both, and see the SMB glossary entry for the protocol background. Old-style transfers on port 21 (FTP) share NFS’s problem of sending credentials and data unencrypted.

Which servers may you test with these checks?

Every check this page links to is for assets you own or are explicitly authorized to test. Never scan, probe, or attempt to connect to a network or device you don’t control. AdminKit’s active checks only ever run against the IP making the request or an asset you’ve verified ownership of. See our Disclaimer and Acceptable Use Policy for the full terms.

This guide is part of AdminKit’s machine protocols cluster, which covers device and file-sharing protocols that are only safe when their exposure is deliberate.

This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.

Frequently asked questions

Why is NFS on the internet riskier than a web server?

Because its default security model trusts the client. The nfs(5) man page explains that AUTH_SYS identifies users by the UID and GID numbers the client sends, and calls it an easy system to spoof that is adequate only on a trusted physical network between trusted hosts. On the internet, every client is untrusted.

Does root_squash protect an exposed export?

Only partly. Root squashing is the default on Linux and maps requests from UID 0 to an anonymous user, but the exports(5) man page notes that it does not apply to other UIDs or GIDs. A client that claims to be any ordinary user can read and write that user's files under AUTH_SYS.

Does AdminKit's port check scan port 2049?

No. The port check tests a fixed list of nine TCP ports (23, 554, 1883, 8883, 502, 7547, 80, 443, 8080) on the public IP you connect from. Test 2049 manually from a machine outside your network with the commands in this guide, and only against servers you own or are authorized to test.

What about port 111?

Port 111 is rpcbind, the service that tells NFS version 2 and 3 clients which ports the mount, lock and status services use. The nfs(5) man page notes that these sideband protocols use no authentication. If 2049 should not face the internet, 111 should not either.

Is NFS with Kerberos safe to expose?

It is much safer than AUTH_SYS: sec=krb5 proves each user's identity, krb5i adds integrity and krb5p encrypts every request. It still exposes a file server's login surface to the whole internet, so a VPN or a narrow address allow-list is the better default even with Kerberos.

Want AdminKit to watch this for you?

Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.

Huy Nguyen (David), Founder and CEO of Netbase JSC

Talk to an expert

Huy Nguyen (David), Founder & CEO, Netbase JSC

Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.