Port 2049 (NFS)

Port 2049 is the port of NFS (Network File System), the protocol Linux and Unix servers use to share folders over the network, so they appear as local…

Key facts

Port
2049
Protocols
TCP, UDP
Range
Registered port, 1024-49151
IANA service name
nfs, shilp

IANA assigns ports in this range to services on request, under RFC 6335.

About port 2049

Port 2049 is the port of NFS (Network File System), the protocol Linux and Unix servers use to share folders over the network, so they appear as local folders. With NFSv4, the connection runs over TCP to port 2049 only, without additional helper services.

NFSv4 is defined in RFC 7530, which sets port 2049 as the service's default port. In the IANA port registry, port 2049 is registered for the nfs service (over TCP, UDP, and SCTP), and also for the shilp service.

What port 2049 is used for

  • Shared storage for several servers: several web servers access the same folder of files, for example files that visitors upload to the site.
  • File server on an internal network: home folders or project folders are kept on one server and mounted on the other computers.
  • Backup target: servers write backups to a shared folder on a storage server.

NFSv3 also requires the rpcbind service on port 111 and the mountd service, in addition to port 2049, so NFSv4 is easier to set up in a firewall.

Port 2049 in the firewall

Don't open port 2049 to the internet. Open it only to the addresses of the servers that mount the folder, preferably on a private network:

  • UFW: ufw allow from 10.0.0.0/24 to any port 2049 proto tcp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="2049" protocol="tcp" accept'

firewalld also has a predefined nfs service, which opens port 2049 over TCP. With NFSv3, you also need to open the rpc-bind and mountd services. Besides the firewall, use /etc/exports to limit which addresses may mount each folder.

Risks and security

With the common setting (sec=sys), the server trusts the user ID the client presents, and doesn't check a password. So anyone who can reach port 2049 and mount the folder may read and change files, which is why limiting access matters. The following settings protect your shared folders:

  • Share each folder only with the addresses or network that need it, for example /srv/share 10.0.0.0/24(rw,sync,root_squash).
  • Keep root_squash, the default, which prevents the root user on the client from getting root permissions on the shared folder.
  • Run NFS traffic over a private network, or through a VPN between the servers.
  • When you need authentication and encryption, set up Kerberos with sec=krb5p, which encrypts every request on the network.

Commands to check and configure

  • exportfs -v

    Shows the shared folders on the server and the settings of each one.

  • exportfs -ra

    Reloads /etc/exports after a change, without restarting the service.

  • mount -t nfs -o vers=4.2 10.0.0.5:/srv/share /mnt/share

    Mounts a shared folder from the given server on the client, at /mnt/share. The vers option sets the NFS version.

  • nfsstat -m

    Shows the mounted NFS folders on the client and the mount options of each one, including the version.

  • ss -tln | grep ':2049 '

    Checks whether an NFS service is listening on port 2049.

  • ufw allow from 10.0.0.0/24 to any port 2049 proto tcp

    Allows access to NFS only from the given private network (UFW).

  • firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="2049" protocol="tcp" accept'

    Allows access to NFS in firewalld only from the given private network. Then run firewall-cmd --reload.

Port 2049 in the IANA registry

Port Protocol Service IANA registry description
2049 SCTP nfs Network File System
2049 TCP nfs Network File System - Sun Microsystems
2049 TCP shilp
2049 UDP nfs Network File System - Sun Microsystems
2049 UDP shilp

Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)

Port 2049 FAQ

What's the difference between NFSv3 and NFSv4?

NFSv4 works on a single port, 2049, and doesn't need helper services, so it's easy to set up in a firewall. NFSv3 also needs the rpcbind service on port 111 and the mountd service. NFSv4 also supports authentication and encryption with Kerberos, along with other improvements.

What's the difference between NFS and SMB?

NFS is the common way to share folders between Linux and Unix servers. SMB, on port 445, is Windows file sharing, and Linux servers support it with Samba. On a network with Windows computers, SMB is usually the one used.

Why do I get "Permission denied" when mounting an NFS folder?

In most cases, the client's address isn't listed in the folder's entry in /etc/exports, or the file was changed and not reloaded. Check the setting on the server with exportfs -v, and if needed reload it with exportfs -ra.

Is NFS a good fit for syncing files between servers?

NFS fits when several servers need to work on the same files in real time. When you only need to copy files from one server to another, for example for a backup, rsync is more convenient. The rsync commands page has examples.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement