Skip to content
ENTERPRISE Enterprise technology · Engineered for your business Enterprise Software · Managed Servers · Business E-mail · LiteSpeed + CloudLinux · Imunify360 Security · cPanel Control · Network profile up to 3 Gbps on eligible plans
AIOR

How to Close Port 111 and Disable Portmapper (rpcbind)

Aior

Administrator

Staff member
Joined
Apr 2, 2023
Messages
929
Reaction score
2
Points
18
Age
41
Location
Turkey
Website
aior.com
Thread owner

Bu başlık, Almanya'nın ulusal siber olaylara müdahale ekibi olan CERT-Bund'dan gelen bir bildirimle açıldı: sunucumuz 111 numaralı portta, internetin her yerinden gelen portmapper sorgularını yanıtlıyordu. Yazının ilk sürümünde o gün çalıştırdığımız dört systemctl komutu vardı. Bu sürüm, aynı bildirim size ulaştığında izleyebileceğiniz bir müdahale kılavuzu (runbook) olarak yeniden yazıldı. Servisin ne olduğunu ve ona neyin bağlı olduğunu anlatıyor. Servisi kalıcı olarak kapatmayı ya da erişimini daraltmayı, portu da sunucunuzda gerçekten kullandığınız güvenlik duvarında (firewall) engellemeyi gösteriyor. Düzeltmeyi dışarıdan doğrulama ve bildirime yanıt verme adımlarıyla bitiyor.

Kısa cevap: Sunucu NFS ya da NIS kullanmıyorsa önce systemctl disable --now rpcbind.socket rpcbind.service, ardından systemctl mask rpcbind.socket rpcbind.service komutlarını çalıştırın. 111/tcp ve 111/udp portlarını IPv4 ve IPv6 için kapatın. Son olarak ağınızın dışındaki bir makineden rpcinfo -u genel-ip-adresiniz 100000 2 (UDP) ve rpcinfo -p genel-ip-adresiniz (TCP) komutlarının ikisinin de yanıt alamadığını doğrulayın; IPv6 adresini de nmap -6 ile kontrol edin (5. bölüm).

1. Portmapper ne işe yarar, 111 numaralı port neden bildirilir?​

ONC RPC servislerinin çoğu ("Sun RPC" ailesi: NFSv3 ve onun mount ve kilit yardımcıları, NIS) sabit bir porta bağlı değildir. Her biri program numarasını, sürümünü ve dinlediği portu makinedeki bir kayıt servisine bildirir; istemciler de 111 numaralı portta çalışan bu servise nereye bağlanacaklarını sorar. Bu işi eskiden portmap adlı servis yapardı; protokol ise hâlâ portmapper adıyla anılır. Güncel Linux dağıtımlarında bu işi rpcbind yapar; protokolün 3. ve 4. sürümlerinin yanında portmapper (2. sürüm) sorgularını da yanıtlar. Ad sık sık "postmapper" diye yanlış yazılır (bu başlıkta da olduğu gibi); doğrusu portmapper'dır.

Servis internetten erişilebilir olduğunda üç sorun doğar:
  • Yansıtma ve yükseltme (reflection/amplification): UDP'de el sıkışma (handshake) yoktur. Bu yüzden saldırgan, kaynak adresi olarak kurbanın IP'sini yazdığı (IP spoofing) küçük bir sorgu gönderebilir. Sunucunuz da çok daha büyük bir yanıtı, yani kayıtlı RPC programlarının listesini, kurbana gönderir. ABD siber güvenlik ajansı CISA'nın UDP tabanlı yükseltme saldırıları hakkındaki TA14-017A uyarısı, Portmap (RPCbind) için bant genişliği yükseltme katsayısını (bandwidth amplification factor) 7 ile 28 arasında verir. Sunucunuz ve bant genişliğiniz, üçüncü bir tarafa yönelik bir DDoS saldırısının parçası olur.
  • Bilgi sızıntısı: Aynı yanıt, hangi RPC servisinin hangi portta çalıştığını gösterir. mountd da erişilebilir durumdaysa showmount -e komutu NFS paylaşımlarınızı (export) listeler.
  • Servisin kendi saldırı yüzeyi: rpcbind servisinde uzaktan tetiklenebilen hatalar görülmüştür. Örneğin CVE-2017-8779 ("rpcbomb") açığında, 111 numaralı porta gönderilen özel olarak hazırlanmış bir UDP paketi, rpcbind servisinin bir daha serbest bırakmadığı bellek ayırmasına yol açar; saldırgan bunu uzaktan hizmet engelleme (DoS) için kullanabilir.

Bu bildirimleri kim gönderir? CERT-Bund raporları, IP bloğu için RIPE veritabanında kayıtlı abuse adresine otomatik olarak gider; sağlayıcılardan da raporu etkilenen müşteriye iletmeleri istenir. BSI'nin SSS sayfasına göre veriler, tüm IPv4 adreslerinin her gün taranmasından gelir. Başka ulusal CERT'ler (örneğin İrlanda'nın NCSC'si) ve barındırma sağlayıcıları da benzer bildirimler gönderir. Bunlar çoğu zaman kâr amacı gütmeyen Shadowserver Vakfı'nın verilerine dayanır. Bize gelen bildirimin Almanca konu satırı "Offene Portmapper-Dienste" ("açık portmapper servisleri") ifadesiyle başlıyordu. Bildirimde IP adresimiz, UTC zaman damgaları ve sunucumuzun döndürdüğü RPC yanıtı yer alıyordu.

2. Kontrol: 111'de ne dinliyor ve neden?​

İşe sunucunun kendisinde başlayın. -n seçeneğini atlamayın; o olmadan ss, port numarası yerine 111'in /etc/services dosyasındaki karşılığı olan "sunrpc" adını yazar ve grep hiçbir şey bulmaz:
Bash:
sudo ss -tulpn | grep ':111'
sudo ss -tulpn 'sport = :111'    # tam eşleşme; grep ise 1110 veya 11111 gibi portları da yakalar
rpcbind soket etkinleştirme ile çalışıyorsa tipik çıktı şöyledir (PID ve fd numaraları sizde farklı olacaktır):
Code:
udp UNCONN 0 0    0.0.0.0:111 0.0.0.0:* users:(("rpcbind",pid=812,fd=5),("systemd",pid=1,fd=41))
tcp LISTEN 0 4096 0.0.0.0:111 0.0.0.0:* users:(("rpcbind",pid=812,fd=4),("systemd",pid=1,fd=40))
udp UNCONN 0 0       [::]:111    [::]:* users:(("rpcbind",pid=812,fd=7),("systemd",pid=1,fd=43))
tcp LISTEN 0 4096    [::]:111    [::]:* users:(("rpcbind",pid=812,fd=6),("systemd",pid=1,fd=42))
Portun sahipleri arasında systemd görünüyorsa bu, soket etkinleştirme (socket activation) demektir (bkz. 3a). [::]:111 satırları ise rpcbind servisinin IPv6 üzerinden de dinlediğini gösterir. Sonra neyin kayıtlı olduğuna ve hangi birimlerin (unit) işin içinde olduğuna bakın:
Bash:
rpcinfo -p localhost
systemctl status rpcbind.socket rpcbind.service
systemctl list-dependencies --reverse rpcbind.socket
rpcinfo yalnızca 100000 numaralı programı (tcp ve udp üzerinde sürüm 2-4 ile portmapper) listeliyorsa şu anda rpcbind servisini kullanan bir şey yoktur. Listede başka bir program numarası varsa, rpcbind servisini neyin kullandığını gösterir:
ProgramAdAnlamı
100000portmapperrpcbind servisinin kendisi
100003nfsbu makine bir NFS sunucusu
100005mountdsunucudaki NFSv3 mount servisi
100021nlockmgrNFSv3 dosya kilitleme (lockd)
100024statusrpc.statd, NFSv3 kilit kurtarma (istemci veya sunucu)
100004 / 100007ypserv / ypbindNIS sunucusu / NIS istemcisi

rpcbind paketini hangi paketin getirdiğini ve kaldırırsanız yanında neyin gideceğini bulun:
Bash:
# Debian / Ubuntu
apt-cache rdepends --installed rpcbind
apt-get -s remove rpcbind        # yalnızca simülasyon: kaldırılacak her şeyi listeler
# RHEL, AlmaLinux, Rocky Linux, CentOS Stream, Fedora
rpm -q --whatrequires rpcbind
Debian ve Ubuntu'da bu genellikle nfs-common, RHEL ailesinde ise nfs-utils paketidir; ikisi de rpcbind paketini zorunlu bağımlılık olarak ister. Son olarak NFS veya NIS'in gerçekten kullanılıp kullanılmadığını kontrol edin:
Bash:
findmnt -t nfs,nfs4              # bu makinede bağlı NFS paylaşımları
nfsstat -m                       # her NFS bağlamasının seçenekleri: vers=3 mü, vers=4.x mi
grep -E '\snfs4?\s' /etc/fstab
for u in nfs-server ypbind ypserv; do echo "$u: $(systemctl is-active $u)"; done
cat /etc/exports 2>/dev/null     # bu makinenin dışa açtığı paylaşımlar

3. Hangi yol size uygun?​

DurumYapılacak
NFS de NIS de yok (tipik web, e-posta ve veritabanı sunucuları)rpcbind servisini durdurun, devre dışı bırakın ve maskeleyin (3a); isterseniz paketi kaldırın; 111'i güvenlik duvarında da kapatın
NFS istemcisi, bütün bağlamalar NFSv4rpcbind ve rpc-statd birimlerini maskeleyin (3a); /etc/fstab içinde vers=4.2 veya 4.1 sabitleyin
NFS sunucusu, bütün istemciler NFSv4 kullanabiliyorSunucuyu yalnızca NFSv4 sunacak şekilde yapılandırın (3b)
Kalması gereken bir NFSv3 istemcisi veya sunucusurpcbind kalsın; 111'e yalnızca güvenilen makinelerden izin verin (3c ve 4. bölüm)

3a. NFS veya NIS yoksa: durdurun, devre dışı bırakın, maskeleyin​

Bash:
sudo systemctl disable --now rpcbind.socket rpcbind.service
sudo systemctl mask rpcbind.socket rpcbind.service
sudo systemctl mask --now rpc-statd.service      # yalnızca nfs-common / nfs-utils kurulu kalacaksa

systemctl is-enabled rpcbind.socket rpcbind.service   # beklenen: masked, masked
sudo ss -tulpn 'sport = :111'                          # beklenen: yalnızca başlık satırı
rpcbind, soket etkinleştirme (socket activation) ile çalışır. rpcbind.socket birimi sayesinde 111 numaralı portu (TCP ve UDP, IPv4 ve IPv6; ayrıca yerel bir Unix soketini) systemd'nin kendisi dinler ve ilk istek geldiğinde rpcbind.service birimini başlatır. Yalnızca servisi durdurursanız systemctl, rpcbind.socket biriminin servisi yeniden başlatabileceği uyarısını verir; nitekim gelen ilk paket servisi yeniden başlatır.

Bu yazının ilk sürümü disable adımında durmuş ve servisin artık başka bir servis tarafından yeniden etkinleştirilemeyeceğini söylemişti. Bu yanlıştı. disable yalnızca enable komutunun oluşturduğu sembolik bağlantıları (symlink) kaldırır; devre dışı bırakılmış bir birim elle ya da bir bağımlılık üzerinden yine başlatılabilir. nfs-utils projesinin kendi (upstream) birim dosyalarında rpc-statd.service, rpcbind.socket birimini zorunlu bağımlılık (Requires) olarak tanımlar; nfs-server.service ise onu zayıf bağımlılık (Wants) olarak çeker. mount.nfs de bir NFSv3 paylaşımını bağlarken rpc-statd servisini başlatır. Bunlardan herhangi biri, bir sonraki yeniden başlatmada ya da bağlamada 111 numaralı portu geri getirir. mask ise birim dosyasını /dev/null'a yönlendiren bir sembolik bağlantı oluşturur; systemctl kılavuzu bunu, elle başlatma dahil her türlü etkinleştirmeyi engelleyen işlem olarak tanımlar. Düzeltmeyi kalıcı yapan adım budur.

Paketi kaldırmak (isteğe bağlı). Debian ve Ubuntu'da simülasyonun listesinde ihtiyacınız olan bir paket yoksa sudo apt purge rpcbind en temiz yoldur; nfs-common da onunla birlikte kaldırılır. NFS araçları üzerine kurulu platformlarda önce bu listeyi okuyun. Örneğin Proxmox VE kullanıcıları, apt paket yöneticisinin proxmox-ve ve pve-manager paketlerini de kaldırmayı önerdiğini bildiriyor; orada kaldırmak yerine maskeleyin. RHEL ailesinde dnf remove rpcbind, nfs-utils paketini ve ona bağlı paketleri de kaldırır; dnf onay istemeden önce işlemin tamamını gösterir. Yalnızca maskelemek de yeterlidir.

3b. NFS sunucusu: yalnızca NFSv4'e geçin​

NFSv4, kilitlemeyi protokolün içinde yapar ve yalnızca 2049/TCP portuna ihtiyaç duyar. nfs(5) kılavuzu, NFSv4 istemcilerinin rpcbind servisine danışmadan doğrudan 2049 numaralı porta bağlandığını belirtir. Red Hat'in "Configuring an NFSv4-only server" yönergesi (RHEL 9 belgeleri) üç ana adımdan oluşur: NFSv3'ü kapatmak, NFSv3 servislerini maskelemek ve rpc.mountd servisinin NFSv3 mount isteklerini dinlemesini bir systemd drop-in dosyasıyla (ek yapılandırma parçası) durdurmak:
INI:
# /etc/nfs.conf
[nfsd]
vers3=n

# /etc/systemd/system/nfs-mountd.service.d/v4only.conf
[Service]
ExecStart=
ExecStart=/usr/sbin/rpc.mountd --no-tcp --no-udp
Bash:
sudo systemctl mask --now rpc-statd.service rpcbind.service rpcbind.socket
sudo systemctl daemon-reload
sudo systemctl restart nfs-mountd nfs-server
sudo firewall-cmd --permanent --add-service=nfs && sudo firewall-cmd --reload   # yalnızca 2049/tcp
cat /proc/fs/nfsd/versions       # -3 görüyorsanız NFSv3 kapalıdır, ör. -3 +4 +4.1 +4.2
sudo ss -tulpn 'sport = :111'    # yalnızca başlık satırı
Debian ve Ubuntu, güncel nfs-utils sürümleriyle aynı /etc/nfs.conf anahtarlarını kullanır; Ubuntu 22.04 ve sonrasında nfsconf --dump, /etc/nfs.conf.d/ dahil geçerli yapılandırmayı gösterir. ExecStart satırını geçersiz kılmadan (override) önce drop-in dosyasını birimin mevcut satırıyla karşılaştırın (systemctl cat nfs-mountd). Sonuç için yapılandırma dosyalarına değil, /proc/fs/nfsd/versions çıktısına güvenin. Çekirdek bu satırda +4.0 yazmaz, çünkü +4 bunu zaten kapsar; bazı çekirdekler satırın başında 2. sürümü de gösterir. Önemli olan -3'tür. İstemcileri, NFSv3'e geri dönmemeleri için vers=4.2 ile bağlayın. Bu sunucuya karşı showmount -e artık çalışmaz; komut mountd servisini RPC üzerinden sorguladığı için bu beklenen bir durumdur.

3c. NFSv3 kalmak zorundaysa: rpcbind kalsın, erişimi daraltın​

NFSv3 kalacaksa rpcbind de kalır ve işi güvenlik duvarı üstlenir. 111 numaralı porta (TCP ve UDP) yalnızca ihtiyaç duyan makinelerden izin verin, diğer herkesten gelen paketleri düşürün (drop). NFSv3 sunucusunda mountd, statd ve lockd, /etc/nfs.conf içinde sabitlenmedikçe rastgele portlar kullanır; bu portları da aynı şekilde kısıtlayın. NFSv3 istemcisinde güvenilen makine NFS sunucusudur. Sunucu, kilitler ve kilit kurtarma için istemcideki lockd ve statd servislerine geri çağrı (callback) yapar. rpcbind servisini yalnızca özel (private) bir IP adresinde dinletmek için rpcbind.socket biriminin Listen satırlarını bir drop-in dosyasıyla değiştirmeniz gerekir (-h seçeneği soket etkinleştirmede yok sayılır); bir güvenlik duvarı kuralını denetlemek ise daha kolaydır.

4. Güvenlik duvarı kuralları: sunucunuzda hangi araç çalışıyorsa​

Önce sunucuda kuralları hangi güvenlik duvarı aracının yönettiğini bulun. Aynı kural setini değiştiren iki ayrı araç, "kapattım ama hâlâ açık" durumlarının sık rastlanan bir sebebidir. Örneklerde 192.0.2.10 güvenilen bir NFS makinesini temsil ediyor; 111'e kimsenin ihtiyacı yoksa bu satırları atlayın.
Bash:
systemctl list-units --type=service --state=active | grep -Ei 'firewalld|ufw|nftables|iptables|netfilter-persistent|csf|lfd'

firewalld (RHEL ailesi)​

Bash:
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all --zone=public
sudo firewall-cmd --permanent --zone=public --remove-service=rpc-bind
sudo firewall-cmd --permanent --zone=public --remove-port=111/tcp --remove-port=111/udp
# isteğe bağlı: tek bir güvenilen istemci
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.0.2.10" service name="rpc-bind" accept'
sudo firewall-cmd --reload
Etkin bölgeniz (zone) public değilse komutlarda onun adını yazın. Varsayılan public bölgesinde rpc-bind servisi yoktur. firewalld çalıştığı hâlde 111'e hâlâ erişilebiliyorsa etkin bölgede bu servisi ya da portu arayın; her şeyi kabul eden trusted bölgesine alınmış bir ağ arayüzü de aynı sonucu doğurur. NOT_ENABLED uyarısı yalnızca o kaydın zaten olmadığını gösterir. Bölge kuralları IPv4 ve IPv6 için aynı şekilde geçerlidir.

nftables​

Bash:
sudo nft list ruleset | grep -n 'dport 111'
sudo nft insert rule inet filter input iifname != lo udp dport 111 drop
sudo nft insert rule inet filter input iifname != lo tcp dport 111 drop
# isteğe bağlı güvenilen makine: en son eklendiği için drop satırlarının üstüne yerleşir
sudo nft insert rule inet filter input ip saddr 192.0.2.10 udp dport 111 accept
sudo nft insert rule inet filter input ip saddr 192.0.2.10 tcp dport 111 accept
Komutlar, Debian'ın varsayılan /etc/nftables.conf dosyasındaki gibi inet filter adlı bir tablo ve input zinciri (chain) olduğunu varsayar; inet tablosu IPv4 ve IPv6 trafiğini birlikte kapsar. iifname != lo kısmı, rpcbind servisinin kaldığı makinelerde loopback arayüzü üzerindeki yerel RPC trafiğini çalışır durumda tutar. Çalışma anında eklenen kurallar yeniden başlatmada kaybolur. Bu yüzden aynı kuralları kalıcı kural dosyanıza da ekleyin: Debian'da /etc/nftables.conf, RHEL ailesinde /etc/sysconfig/nftables.conf üzerinden yüklenen dosya. firewalld çalışan makinede bunun yerine firewall-cmd kullanın.

iptables ve ip6tables​

Bash:
sudo iptables -S INPUT | grep -- '--dport 111'
# önce isteğe bağlı güvenilen makine, sonra drop kuralları
sudo iptables -I INPUT 1 -s 192.0.2.10 -p udp --dport 111 -j ACCEPT
sudo iptables -I INPUT 2 -s 192.0.2.10 -p tcp --dport 111 -j ACCEPT
sudo iptables -I INPUT 3 ! -i lo -p udp --dport 111 -j DROP
sudo iptables -I INPUT 4 ! -i lo -p tcp --dport 111 -j DROP
# IPv6 için ayrı bir tablo var
sudo ip6tables -I INPUT 1 ! -i lo -p udp --dport 111 -j DROP
sudo ip6tables -I INPUT 2 ! -i lo -p tcp --dport 111 -j DROP
Güvenilen makine yoksa IPv4 drop kurallarını 1. ve 2. sıraya ekleyin; ! -i lo kısmı loopback trafiğine dokunmaz. Kuralları kaydedin, yoksa bir sonraki yeniden başlatmada kaybolurlar. Debian ve Ubuntu'da iptables-persistent paketiyle birlikte kurulan netfilter-persistent save komutunu kullanın. iptables-services kullanan RHEL ailesinde ise service iptables save ve service ip6tables save komutlarını çalıştırın.

ufw (Ubuntu)​

Bash:
sudo ufw status verbose          # etkin mi? gelen trafik için varsayılan politika ne?
sudo ufw status numbered
sudo ufw delete 5                # 111'e izin veren kuralın numarasını yazın
# isteğe bağlı güvenilen makine, ardından açık bir deny kuralı
sudo ufw allow from 192.0.2.10 to any port 111
sudo ufw deny 111
"Default: deny (incoming)" görüyorsanız 111'i yalnızca bir izin kuralı açabilir; "Status: inactive" ise ufw'nin hiçbir şeyi filtrelemediği anlamına gelir. proto belirtilmeyen bir kural TCP ve UDP'yi birlikte kapsar. /etc/default/ufw içinde IPV6=yes ise (Ubuntu'nun varsayılanı) kural IPv6 için de geçerli olur.

cPanel ve DirectAdmin sunucularında CSF​

CSF (ConfigServer Security & Firewall) yalnızca /etc/csf/csf.conf içinde listelenen portları açar. Önce dört port listesine (TCP_IN, UDP_IN, TCP6_IN, UDP6_IN) ve doğru bir listeyi boşa çıkarabilecek iki ayara bakın:
Bash:
grep -nE '^(TESTING|IPV6|TCP_IN|UDP_IN|TCP6_IN|UDP6_IN) ' /etc/csf/csf.conf
111 hangi listelerde geçiyorsa oradan yalnızca 111'i silin, diğer portlara dokunmayın. cPanel ve DirectAdmin sunucularında bu listelerde panelin kendi portları da bulunur (ör. cPanel'de 2083 ve 2087, DirectAdmin'de 2222); listeyi bir örnekle değiştirmek sizi panelin dışında bırakabilir. Hedef durum:
INI:
# önce:  UDP_IN = "20,21,53,111,853,80,443"
# sonra: UDP_IN = "20,21,53,853,80,443"
TESTING = "0"
# yalnızca sunucunun bir IPv6 adresi varsa:
IPV6 = "1"
Varsayılan TESTING = "1" değeri, csf her başlatıldığında bir cron görevi ekler. Bu görev en geç TESTING_INTERVAL dakika (varsayılan 5) içinde csf -f komutunu çalıştırır; bu komut bütün kuralları siler ve cron görevini de kaldırır. Sunucu, csf yeniden başlatılana kadar filtresiz kalır. Varsayılan csf.conf dosyasında IPV6 = "0" yazar; kurulum sırasında çalışan otomatik yapılandırma betiği, ip6tables ve bir IPv6 adresi bulursa (OpenVZ/Virtuozzo konteynerleri hariç) bunu "1" yapar. Değer "0" ise CSF IPv6 trafiğine hiç dokunmaz. Durdurulmuş bir csf hiç kural bırakmaz; firewalld etkinse csf başlamayı reddeder. Güvenilen bir makine için portu açmak yerine /etc/csf/csf.allow dosyasına gelişmiş filtreler (advanced filters) ekleyin:
Code:
tcp|in|d=111|s=192.0.2.10
udp|in|d=111|s=192.0.2.10
Değişikliği sudo csf -r ile, lfd'yi de yeniden başlatmak için sudo csf -ra ile uygulayın. ConfigServer'ın arkasındaki şirket Ağustos 2025'te kapandı ve CSF'yi GPLv3 lisansıyla yayımladı. cPanel bakımını üstlendiği bir çatal (fork) duyurdu, topluluk çatalları da var; sunucunuzda hangi sürümün çalıştığını kontrol edin. Yukarıdaki anahtarlar özgün csf.conf dosyasındaki anahtarlardır.

Sağlayıcı veya bulut güvenlik duvarı​

Aynı kısıtlamayı sağlayıcınızın ağ güvenlik duvarında ya da güvenlik grubunda (security group) da uygulayın. Bunların çoğu izin listesi (allow-list) mantığıyla çalışır, yani 111 listede yer almamalıdır. IPv4 ve IPv6 kurallarını ayrı ayrı kontrol edin. Bu katman, sunucudaki güvenlik duvarı yanlışlıkla boşaltılsa bile korumayı sürdürür.

5. Dışarıdan doğrulayın: IPv4 ve IPv6​

Testi ağınızın dışından yapın; örneğin başka bir sağlayıcıdaki bir sunucudan. BSI'nin portmapper HOWTO sayfası, testin sunucunun kendisinde veya yerel ağda yapılmamasını söyler. nmap'in UDP taraması (-sU) root yetkisi ister. rpcinfo ve showmount, rpcbind ve NFS istemci paketleriyle gelir; ama tek başına nmap de yeterlidir. rpcinfo için test makinesine rpcbind kurarsanız oradaki servisi de maskeleyin; uzak sorgular yerel rpcbind servisine ihtiyaç duymaz. Örneklerdeki 203.0.113.25 ve 2001:db8::25, belgelerde kullanılmak üzere ayrılmış adreslerdir; yerlerine kendi adreslerinizi yazın.
Bash:
sudo nmap -sU -sT -p 111 203.0.113.25
sudo nmap -sU -sV -p 111 203.0.113.25      # "open" ile "open|filtered" sonucunu ayırır
rpcinfo -u 203.0.113.25 100000 2           # UDP: 111/udp üzerinden portmapper'a ping
rpcinfo -p 203.0.113.25                    # TCP: kayıtlı programların dökümü
showmount -e 203.0.113.25
sudo nmap -6 -sU -sT -p 111 2001:db8::25   # test makinesinde IPv6 olmalı
BSI'nin HOWTO sayfasında ve başka kılavuzlarda geçen rpcinfo -T udp -p komutu, güncel Linux dağıtımlarındaki rpcinfo ile UDP'yi sınamaz. rpcbind 1.2.5-1.2.7 kaynak koduna göre -p seçeneği -T değerini kullanmaz ve sorguyu her zaman TCP üzerinden yapar. 111/tcp kapalı ama 111/udp açıksa, yani tam da yansıtma saldırısında kullanılan durumda, bu komut hata verir ve sorun çözülmüş gibi görünür. UDP tarafını rpcinfo -u ya da nmap -sU ile sınayın.
SonuçAnlamı
111/tcp closed veya filteredTCP tarafı düzeltilmiş
111/udp closedDüzeltilmiş: dinleyen yok ya da güvenlik duvarı reddediyor (reject)
111/udp open|filteredYanıt gelmedi; DROP kuralıyla beklenen sonuç budur, rpcinfo -u ile teyit edin
111/udp open, servis rpcbindHâlâ açık
rpcinfo -u: program 100000 version 2 ready and waitingHâlâ açık: 111/udp yanıt veriyor, yansıtmada kullanılan taraf da bu
rpcinfo -u bir RPC hatasıyla bitiyor, genellikle Timed out (yaklaşık bir dakika sonra) ya da Unable to receive; tam metin sürüme göre değişirUDP tarafı düzeltilmiş
rpcinfo -p bir program listesi yazdırıyorHâlâ açık (TCP)
rpcinfo -p: RPC: Remote system error - Connection timed out ya da Connection refusedTCP tarafı düzeltilmiş
Testi bir sonraki yeniden başlatmadan sonra tekrarlayın; yalnızca devre dışı bırakılmış bir servis tam da o anda geri gelir.

6. CERT'e veya abuse bildirimine yanıtta ne yazmalı?​

Bildirimi sağlayıcınız ilettiyse yanıtı onun kanalından ve verdiği süre içinde gönderin. Bir CERT size doğrudan yazdıysa bildirimdeki talimatları izleyin. Etkilenen IPv4 ve IPv6 adreslerini, nedeni, UTC saatiyle düzeltmeyi, dışarıdan doğrulamayı ve sorunun tekrarlanmasını neyin engellediğini yazın. BSI, CERT-Bund raporlarının dijital olarak imzalandığını belirtir. Şüpheli görünen bir e-postada bağlantılara tıklamak yerine kendi IP adresinizi kendiniz test edin. Yabancı bir CERT'e veya sağlayıcıya yazıyorsanız aynı maddeleri İngilizce yazın; bu başlığın İngilizce sürümünde hazır bir örnek var.
Code:
Konu: Re: <bilet veya rapor numarası> 203.0.113.25 üzerinde açık portmapper

Merhaba,

Bildirilen bulgu doğrulandı ve giderildi.

Sunucu: 203.0.113.25 (IPv6: 2001:db8::25)
Neden: rpcbind, NFS istemci araçlarının bağımlılığı olarak kurulmuştu ve
111/tcp ile 111/udp üzerinde dinliyordu. Sunucuda NFS veya NIS kullanılmıyor.
Düzeltme (27.10.2026 09:40 UTC): rpcbind.socket ve rpcbind.service
durduruldu ve maskelendi; 111/tcp ve 111/udp sunucu güvenlik duvarında
(IPv4 ve IPv6) ve sağlayıcının ağ güvenlik duvarında kapatıldı.
Doğrulama (27.10.2026 09:55 UTC, harici bir makineden):
"rpcinfo -u 203.0.113.25 100000 2" (UDP) ve "rpcinfo -p 203.0.113.25" (TCP)
yanıt alamıyor; nmap hem IPv4 hem IPv6 adresinde 111/tcp için filtered,
111/udp için RPC yanıtı olmadan open|filtered gösteriyor.
Önleme: 111 numaralı port haftalık dış port kontrolümüze eklendi.

Saygılarımızla,
<ad, şirket, iletişim>

7. Önleme: minimal kurulum ve dış taramalar​

Minimal kurulum. Minimal bir imajla başlayın ve NFS istemci araçlarını yalnızca NFS paylaşımı bağlayan makinelere kurun. Sunucuyu hazırladıktan ve yeni paket kurduktan sonra ss -tulpn çıktısını beklediğiniz servis listesiyle karşılaştırın.

İki katmanda varsayılan engelleme (default-deny). Sunucu güvenlik duvarı da sağlayıcı güvenlik duvarı da yalnızca gerçekten hizmet verdiğiniz portları listelesin. Yapılandırma yönetimi aracınız (Ansible vb.) da yeniden kurulan sunucularda rpcbind servisini maskeli tutsun.

Sunucularınızı düzenli olarak dışarıdan tarayın; bunu başka bir ağdaki bir makineden yapın:
Bash:
#!/bin/sh
# /usr/local/bin/check-portmapper.sh: ağınızın DIŞINDAKİ bir makinede çalıştırın
# crontab: 0 6 * * 1 /usr/local/bin/check-portmapper.sh
# IPv6 adresleri için 5. bölümdeki nmap -6 kontrolünü aynı takvime ekleyin
for ip in 203.0.113.25 203.0.113.26; do
  if timeout 30 rpcinfo -u "$ip" 100000 2 >/dev/null 2>&1; then
    echo "UYARI: $ip üzerinde portmapper 111/udp üzerinden yanıt veriyor"
  fi
  if timeout 30 rpcinfo -p "$ip" >/dev/null 2>&1; then
    echo "UYARI: $ip üzerinde portmapper 111/tcp üzerinden yanıt veriyor"
  fi
done
Yerel posta çalışıyorsa cron çıktıyı e-postayla gönderir; çalışmıyorsa çıktıyı kendi uyarı sisteminize yönlendirin. Bir ASN'yi veya IP bloklarını yönetiyorsanız Shadowserver'ın ağ sahiplerine ücretsiz gönderdiği günlük raporlara abone olabilirsiniz. CISA listesindeki diğer UDP yansıtıcılarını da kontrol edin; NTP (123/udp), SNMP (161/udp), SSDP (1900/udp) ve Memcached (11211/udp) bunlardan birkaçıdır.

Sorun giderme​

BelirtiOlası nedenÇözüm
"Warning: Stopping rpcbind.service, but it can still be activated by: rpcbind.socket" (systemd 254 ve öncesi) ya da "Stopping 'rpcbind.service', but its triggering units are still active: rpcbind.socket" (systemd 255 ve sonrası)Yalnızca servis durduruldurpcbind.socket birimini de devre dışı bırakıp maskeleyin
111 yeniden başlatmadan veya paketin yeniden kurulmasından sonra geri geldiBirimler maskelenmemiş, yalnızca devre dışı bırakılmış: nfs-server, rpc-statd veya bir NFSv3 bağlaması rpcbind.socket birimini başlattı ya da yeniden kurulum birimi tekrar etkinleştirdiİki birimi de maskeleyin (maske /etc/systemd/system altında durur, güncellemeler ona dokunmaz); systemctl list-dependencies --reverse rpcbind.socket çıktısına bakın
Her şey maskeli ama 111'de hâlâ bir şey dinliyorBaşka bir süreç; örneğin host ağını kullanıp kendi rpcbind servisini çalıştıran bir konteyner ya da 111 numaralı portu yayımlayan bir konteyner için docker-proxyss -tulpn çıktısındaki süreç sütununu okuyun ve o servisle ilgilenin
mount.nfs: rpc.statd is not running but is required for remote lockingMakine bir NFSv3 paylaşımı bağlıyorSunucu destekliyorsa vers=4.2 ile bağlayın; desteklemiyorsa maskeyi kaldırın (unmask), rpcbind kalsın ve 3c'yi izleyin
NFSv4'e geçişten sonra istemciler bağlanamıyorİstemciler NFSv3 istiyor ya da bir betik showmount -e komutuna dayanıyorİstemcilerde vers=4.2 veya 4.1 kullanın; sunucuda /proc/fs/nfsd/versions çıktısını kontrol edin
111 hiçbir CSF listesinde yok ama hâlâ açıkTESTING = "1" kuralları her başlatmadan birkaç dakika sonra siliyor; IPV6 = "0"; csf durmuş ya da firewalld etkin olduğu için hiç başlamamışTESTING = "0" yapın (sunucuda IPv6 varsa IPV6 = "1"), firewalld'yi durdurup devre dışı bırakın, csf -ra çalıştırın

Sıkça sorulan sorular​

Web veya e-posta sunucusunda rpcbind servisini kapatmak güvenli mi?
Genellikle evet. Tipik bir web, e-posta veya veritabanı yazılım yığını ONC RPC kullanmaz. İstisnalar NFSv3 bağlamaları (yedeklerin bir NFS paylaşımına yazılması sık görülen bir örnektir), NIS ile oturum açma ve rpcbind servisine kaydolan nadir eski araçlardır; 2. bölümdeki kontroller üçünü de ortaya çıkarır.

NFSv4 için 111 numaralı port gerekli mi?
Hayır. NFSv4, TCP 2049'u kullanır ve kilitlemeyi protokolün içinde yapar. rpcbind ise NFSv2, NFSv3 ve bunların yardımcı servisleri (mountd, statd, lockd) ile NIS için gereklidir.

Bir güvenlik duvarı kuralı yetmez mi?
Açığı kapatır; NFSv3 kullanan bir makinede de asıl kontrol odur. Ama kural setleri boşalabilir ya da kaybolabilir: CSF'nin test modu kuralları siler, kimsenin kaydetmediği bir iptables kuralı da ilk yeniden başlatmada gider. Maskeleme dinleyen servisi ortadan kaldırır; böylece güvenlik duvarındaki bir hata sorunu geri getirmez.

Bildirim yalnızca IPv4'ten söz ediyor. IPv6'yı da kontrol etmem gerekir mi?
Evet. BSI'nin SSS sayfası IPv4 adreslerinin tarandığını anlatır; yani IPv6 üzerindeki bir açık bu raporlarda hiç görünmeyebilir. Oysa rpcbind.socket varsayılan olarak [::]:111 adresini de dinler ve yalnızca IPv4'e uygulanan bir kural (ip6tables olmadan iptables ya da IPV6 = "0" ayarlı CSF) bu kapıyı açık bırakır.

Bildirimler ne zaman kesilir?
BSI'nin SSS sayfasına göre sorun giderildikten sonra daha yeni zaman damgalı bir bildirim gelmemesi gerekir. Düzeltmeden sonra gelen ama zaman damgası düzeltmeden önceye ait olan bildirim, eski bir taramanın sonucudur. Daha yeni zaman damgalı bir bildirim ise portun bir yerde, belki başka bir IP adresinizde, hâlâ erişilebilir olduğunu gösterir.

Sonuç ve sonraki adımlar​

Açık portmapper sorunu kısa sürede çözülür ve sık yapılan hatalar bellidir: rpcbind maskelenmeden yalnızca devre dışı bırakılır, IPv4 kapatılırken IPv6 açık unutulur ya da UDP tarafı yalnızca TCP'yi sınayan rpcinfo -p ile "doğrulanır". rpcbind servisini neyin kullandığını bulun. Hiçbir şey kullanmıyorsa servisi maskeleyin; makine bir NFS sunucusuysa onu yalnızca NFSv4'e geçirin. 111'i gerçekten kullandığınız güvenlik duvarında kısıtlayın, iki IP sürümünde hem TCP'yi hem UDP'yi dışarıdan test edin ve bildirime saat ve kanıtla yanıt verin. Sonraki adım olarak dış kontrolü takvime bağlayın. Daha geniş bir sıkılaştırma (hardening) temeli için 2026'da Sunucu Sıkılaştırma: Canlı Linux Sunucular için Asgari Güvenlik ve Canlı Sistemler için Sunucu Sıkılaştırma: Paranoyasız Katmanlı Savunma başlıklarını inceleyin. Bu işi bir ekibe bırakmak isterseniz AIOR'un siber güvenlik, yedekleme ve veri koruma hizmetleri sunucu sıkılaştırmayı ve port güvenliğini kapsar. Kendi dağıtımınıza veya kontrol panelinize özel sorularınızı bu başlıkta sorabilirsiniz.

A notice from CERT-Bund, Germany's national CERT, started this thread: our server was answering portmapper requests on port 111 from anywhere on the internet. The first version of this post listed the four systemctl commands we ran. This revision is a runbook for the day the same notice reaches you. It covers what the service is, what depends on it, how to switch it off for good or restrict it, and how to close the port in the firewall you actually use. It ends with how to prove the fix from outside and answer the report.

Short answer: if the server uses neither NFS nor NIS, run systemctl disable --now rpcbind.socket rpcbind.service, then systemctl mask rpcbind.socket rpcbind.service. Block 111/tcp and 111/udp for IPv4 and IPv6, and confirm from a host outside your network that neither rpcinfo -u your-public-ip 100000 2 (UDP) nor rpcinfo -p your-public-ip (TCP) gets an answer. Check the IPv6 address with nmap -6 as well (section 5).

1. What portmapper does and why port 111 gets reported​

Most ONC RPC services (the "Sun RPC" family: NFSv3 with its mount and lock helpers, NIS) are not tied to fixed ports. Each registers its program number and version with a local directory, and clients ask that directory, on port 111, where to connect. The old daemon was called portmap and the protocol is still known as portmapper. Current Linux distributions run rpcbind, which answers portmapper (version 2) queries alongside versions 3 and 4. You will also see the name misspelled "postmapper", as in this thread's title; the correct term is portmapper.

When the service is reachable from the internet, it causes three problems:
  • Reflection and amplification: UDP has no handshake, so an attacker can send a small query with the victim's address forged as the source. Your server then sends its much larger answer, the list of registered RPC programs, to the victim. CISA's alert TA14-017A on UDP-based amplification attacks lists Portmap (RPCbind) with a bandwidth amplification factor of 7 to 28. Your server and your bandwidth become part of a DDoS attack on a third party.
  • Information disclosure: the same answer shows which RPC services run on which ports. If mountd is reachable too, showmount -e lists your NFS exports.
  • Its own attack surface: rpcbind has had remotely triggerable bugs, such as CVE-2017-8779 ("rpcbomb"), where a crafted UDP packet to port 111 makes rpcbind allocate memory that it never frees, allowing a remote denial of service.

Who sends these notices. CERT-Bund reports go automatically to the abuse contact registered at RIPE for the IP range, and providers are asked to forward them to the affected customer. According to the BSI's FAQ, the data comes from daily scans of all IPv4 addresses. Other national CERTs (Ireland's NCSC, for example) and hosting providers send similar notices, often based on data from the non-profit Shadowserver Foundation. Ours had a German subject beginning "Offene Portmapper-Dienste" (open portmapper services) and listed our IP, UTC timestamps and the RPC response our server had returned.

2. Check what is listening and why​

Start on the server. Keep -n, otherwise ss prints "sunrpc" (the /etc/services name for port 111) and the grep finds nothing:
Bash:
sudo ss -tulpn | grep ':111'
sudo ss -tulpn 'sport = :111'    # exact match; the grep also matches ports such as 1110 or 11111
Typical output when rpcbind is socket-activated (PIDs and fd numbers will differ):
Code:
udp UNCONN 0 0    0.0.0.0:111 0.0.0.0:* users:(("rpcbind",pid=812,fd=5),("systemd",pid=1,fd=41))
tcp LISTEN 0 4096 0.0.0.0:111 0.0.0.0:* users:(("rpcbind",pid=812,fd=4),("systemd",pid=1,fd=40))
udp UNCONN 0 0       [::]:111    [::]:* users:(("rpcbind",pid=812,fd=7),("systemd",pid=1,fd=43))
tcp LISTEN 0 4096    [::]:111    [::]:* users:(("rpcbind",pid=812,fd=6),("systemd",pid=1,fd=42))
When systemd is listed as an owner of the port, rpcbind is socket-activated (section 3a). The [::]:111 lines mean rpcbind listens on IPv6 as well. Next, see what is registered and which units are involved:
Bash:
rpcinfo -p localhost
systemctl status rpcbind.socket rpcbind.service
systemctl list-dependencies --reverse rpcbind.socket
If rpcinfo lists only program 100000 (portmapper, versions 2 to 4, tcp and udp), nothing uses rpcbind right now. Any other program number tells you who does:
ProgramNameMeaning
100000portmapperrpcbind itself
100003nfsthis host is an NFS server
100005mountdNFSv3 mount service on a server
100021nlockmgrNFSv3 file locking (lockd)
100024statusrpc.statd, NFSv3 lock recovery (client or server)
100004 / 100007ypserv / ypbindNIS server / NIS client

Find the package that pulled rpcbind in, and what removing it would take along:
Bash:
# Debian / Ubuntu
apt-cache rdepends --installed rpcbind
apt-get -s remove rpcbind        # simulation only: lists everything that would be removed
# RHEL, AlmaLinux, Rocky Linux, CentOS Stream, Fedora
rpm -q --whatrequires rpcbind
It is usually nfs-common on Debian and Ubuntu, or nfs-utils on the RHEL family; both require rpcbind. Finally, check whether NFS or NIS is really in use:
Bash:
findmnt -t nfs,nfs4              # NFS shares mounted on this host
nfsstat -m                       # options of each NFS mount: vers=3 or vers=4.x
grep -E '\snfs4?\s' /etc/fstab
for u in nfs-server ypbind ypserv; do echo "$u: $(systemctl is-active $u)"; done
cat /etc/exports 2>/dev/null     # shares this host exports

3. Decide which path is yours​

SituationAction
No NFS, no NIS (typical web, mail and database servers)Stop, disable and mask rpcbind (3a); optionally remove the package; block 111 anyway
NFS client, every mount is NFSv4Mask rpcbind and rpc-statd (3a); pin vers=4.2 or 4.1 in /etc/fstab
NFS server, every client can use NFSv4Convert it to an NFSv4-only server (3b)
An NFSv3 client or server that must stayKeep rpcbind; allow 111 only from trusted hosts (3c and section 4)

3a. No NFS or NIS: stop, disable and mask​

Bash:
sudo systemctl disable --now rpcbind.socket rpcbind.service
sudo systemctl mask rpcbind.socket rpcbind.service
sudo systemctl mask --now rpc-statd.service      # only if nfs-common / nfs-utils stays installed

systemctl is-enabled rpcbind.socket rpcbind.service   # expect: masked, masked
sudo ss -tulpn 'sport = :111'                          # expect: the header line only
rpcbind uses socket activation. rpcbind.socket makes systemd itself listen on 111 (TCP and UDP, IPv4 and IPv6, plus a local Unix socket) and starts rpcbind.service on the first request. If you stop only the service, systemctl warns that rpcbind.socket can still activate it, and the next packet does exactly that.

The first version of this post stopped at disable and claimed the service could no longer be reactivated by another service. That was wrong. disable only removes the symlinks that enable created, so a disabled unit can still be started by hand or as a dependency. In the upstream nfs-utils units, rpc-statd.service requires rpcbind.socket and nfs-server.service wants it. mount.nfs also starts rpc-statd when it mounts an NFSv3 share. Any of these brings port 111 back at the next reboot or mount. mask links the unit to /dev/null, which the systemctl manual describes as prohibiting all kinds of activation, manual starts included. That is what makes the fix stick.

Removing the package (optional). On Debian and Ubuntu, sudo apt purge rpcbind is clean when the simulation lists nothing you need; nfs-common goes with it. Read that list first on platforms built on the NFS tools. Proxmox VE users, for example, report apt proposing to remove proxmox-ve and pve-manager too, so mask instead. On the RHEL family, dnf remove rpcbind also removes nfs-utils and its dependents, showing the transaction before it asks. Masking alone is enough.

3b. NFS server: switch to NFSv4-only​

NFSv4 handles locking inside the protocol and needs only TCP 2049. The nfs(5) manual notes that NFSv4 clients connect to 2049 without consulting rpcbind. Red Hat's procedure "Configuring an NFSv4-only server" (RHEL 9 documentation) has three parts: turn NFSv3 off, mask the NFSv3 services, and stop rpc.mountd from listening for NFSv3 mount requests:
INI:
# /etc/nfs.conf
[nfsd]
vers3=n

# /etc/systemd/system/nfs-mountd.service.d/v4only.conf
[Service]
ExecStart=
ExecStart=/usr/sbin/rpc.mountd --no-tcp --no-udp
Bash:
sudo systemctl mask --now rpc-statd.service rpcbind.service rpcbind.socket
sudo systemctl daemon-reload
sudo systemctl restart nfs-mountd nfs-server
sudo firewall-cmd --permanent --add-service=nfs && sudo firewall-cmd --reload   # 2049/tcp only
cat /proc/fs/nfsd/versions       # NFSv3 is off when you see -3, e.g. -3 +4 +4.1 +4.2
sudo ss -tulpn 'sport = :111'    # header line only
Debian and Ubuntu use the same /etc/nfs.conf keys with current nfs-utils; on Ubuntu 22.04 and later, nfsconf --dump shows the effective result, /etc/nfs.conf.d/ included. Compare the drop-in with your unit's current ExecStart (systemctl cat nfs-mountd) before overriding it, and trust /proc/fs/nfsd/versions over any config file. The kernel never prints +4.0 there, because +4 already implies it, and some kernels also list version 2 at the start; -3 is what matters. Mount the clients with vers=4.2 so they never fall back to NFSv3. showmount -e stops working against this server; that is expected, because it asks mountd over RPC.

3c. NFSv3 must stay: keep rpcbind, restrict it​

If NFSv3 must stay, so does rpcbind, and the firewall does the work. Allow 111 (TCP and UDP) only from the hosts that need it and drop it for everyone else. On an NFSv3 server, mountd, statd and lockd use random ports unless you pin them in /etc/nfs.conf, so restrict those the same way. On an NFSv3 client, the trusted host is the NFS server, which calls back the client's lockd and statd for locks and lock recovery. Binding rpcbind to a private address means overriding the Listen lines of rpcbind.socket with a drop-in (its -h option is ignored under socket activation), and a firewall rule is easier to audit.

4. Firewall recipes for the tool your server runs​

First find out which firewall tool manages the rules. Two tools editing one rule set are a common cause of "closed, but still open" cases. In the examples, 192.0.2.10 stands for a trusted NFS host; skip those lines if nobody needs 111.
Bash:
systemctl list-units --type=service --state=active | grep -Ei 'firewalld|ufw|nftables|iptables|netfilter-persistent|csf|lfd'

firewalld (RHEL family)​

Bash:
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all --zone=public
sudo firewall-cmd --permanent --zone=public --remove-service=rpc-bind
sudo firewall-cmd --permanent --zone=public --remove-port=111/tcp --remove-port=111/udp
# optional: a single trusted client
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.0.2.10" service name="rpc-bind" accept'
sudo firewall-cmd --reload
If your active zone is not public, use its name in the commands. The default public zone has no rpc-bind. If 111 is still reachable while firewalld runs, look for the service or port in the active zone, or an interface in the trusted zone, which accepts everything. A NOT_ENABLED warning only means the entry was not there. Zone rules cover IPv4 and IPv6 alike.

nftables​

Bash:
sudo nft list ruleset | grep -n 'dport 111'
sudo nft insert rule inet filter input iifname != lo udp dport 111 drop
sudo nft insert rule inet filter input iifname != lo tcp dport 111 drop
# optional trusted host: inserted last, so these land above the drops
sudo nft insert rule inet filter input ip saddr 192.0.2.10 udp dport 111 accept
sudo nft insert rule inet filter input ip saddr 192.0.2.10 tcp dport 111 accept
This assumes a table inet filter with an input chain, as in Debian's default /etc/nftables.conf; an inet table covers IPv4 and IPv6 together. The iifname != lo part keeps local RPC on the loopback interface working where rpcbind stays. Runtime rules vanish at reboot, so add the same rules to your saved ruleset: /etc/nftables.conf on Debian, or the file loaded via /etc/sysconfig/nftables.conf on the RHEL family. Where firewalld runs, use firewall-cmd instead.

iptables and ip6tables​

Bash:
sudo iptables -S INPUT | grep -- '--dport 111'
# optional trusted host first, then the drops
sudo iptables -I INPUT 1 -s 192.0.2.10 -p udp --dport 111 -j ACCEPT
sudo iptables -I INPUT 2 -s 192.0.2.10 -p tcp --dport 111 -j ACCEPT
sudo iptables -I INPUT 3 ! -i lo -p udp --dport 111 -j DROP
sudo iptables -I INPUT 4 ! -i lo -p tcp --dport 111 -j DROP
# IPv6 has its own table
sudo ip6tables -I INPUT 1 ! -i lo -p udp --dport 111 -j DROP
sudo ip6tables -I INPUT 2 ! -i lo -p tcp --dport 111 -j DROP
Without a trusted host, insert the IPv4 drops at positions 1 and 2; ! -i lo leaves loopback traffic alone. Save the rules, or they vanish at the next reboot. On Debian and Ubuntu use netfilter-persistent save (installed with iptables-persistent). On the RHEL family with iptables-services, use service iptables save and service ip6tables save.

ufw (Ubuntu)​

Bash:
sudo ufw status verbose          # active? default policy for incoming?
sudo ufw status numbered
sudo ufw delete 5                # use the number of any rule that allows 111
# optional trusted host, followed by an explicit deny
sudo ufw allow from 192.0.2.10 to any port 111
sudo ufw deny 111
With "Default: deny (incoming)", only an allow rule opens 111; "Status: inactive" means ufw filters nothing. A rule without proto covers TCP and UDP. It covers IPv6 too when /etc/default/ufw has IPV6=yes, which is Ubuntu's default.

CSF on cPanel and DirectAdmin servers​

CSF (ConfigServer Security & Firewall) opens only the ports listed in /etc/csf/csf.conf. Start by reading the four port lists (TCP_IN, UDP_IN, TCP6_IN, UDP6_IN) and the two settings that can undo a correct list:
Bash:
grep -nE '^(TESTING|IPV6|TCP_IN|UDP_IN|TCP6_IN|UDP6_IN) ' /etc/csf/csf.conf
Delete 111 from every list that contains it and leave every other port alone. On cPanel and DirectAdmin servers these lists also hold the panel's own ports (for example 2083 and 2087 on cPanel, 2222 on DirectAdmin), so replacing a list with a sample can lock you out of the panel. The target state:
INI:
# before: UDP_IN = "20,21,53,111,853,80,443"
# after:  UDP_IN = "20,21,53,853,80,443"
TESTING = "0"
# only if the server has an IPv6 address:
IPV6 = "1"
TESTING = "1", the shipped value, adds a cron job at every csf start. Within TESTING_INTERVAL minutes (5 by default) the job runs csf -f, which flushes every rule and removes the job, and the server stays unfiltered until csf is started again. The shipped file also says IPV6 = "0"; the installer's auto-configuration switches it to "1" when it finds ip6tables and an IPv6 address (except in OpenVZ/Virtuozzo containers). With "0", CSF leaves IPv6 traffic alone. A stopped csf leaves no rules at all, and csf refuses to start while firewalld is active. For a trusted host, use advanced filters in /etc/csf/csf.allow instead of opening the port:
Code:
tcp|in|d=111|s=192.0.2.10
udp|in|d=111|s=192.0.2.10
Apply with sudo csf -r, or sudo csf -ra to restart lfd as well. The company behind ConfigServer closed in August 2025 and released CSF under GPLv3. cPanel has announced a fork it maintains, and community forks exist as well, so check which build your server runs; the keys above are those of the original csf.conf.

Provider or cloud firewall​

Repeat the restriction in your provider's network firewall or security group. Most of these are allow-lists, so 111 simply must not be listed. Check the IPv4 and IPv6 rules separately. This layer still holds if the host firewall gets flushed by mistake.

5. Verify from outside, over IPv4 and IPv6​

Test from outside your network, for example from a server at another provider. The BSI's portmapper HOWTO warns against testing on the host itself or from the local network. nmap's UDP scan (-sU) needs root. rpcinfo and showmount come with the rpcbind and NFS client packages, but nmap alone is enough. If you install rpcbind on the test host to get rpcinfo, mask the service there too; remote queries do not need a local rpcbind. 203.0.113.25 and 2001:db8::25 are documentation addresses; use your own.
Bash:
sudo nmap -sU -sT -p 111 203.0.113.25
sudo nmap -sU -sV -p 111 203.0.113.25      # separates "open" from "open|filtered"
rpcinfo -u 203.0.113.25 100000 2           # UDP: ping portmapper over 111/udp
rpcinfo -p 203.0.113.25                    # TCP: dump the registered programs
showmount -e 203.0.113.25
sudo nmap -6 -sU -sT -p 111 2001:db8::25   # the test machine needs IPv6
The BSI's HOWTO and other guides use rpcinfo -T udp -p, but with the rpcinfo that current Linux distributions ship, that command does not test UDP. In the rpcbind 1.2.5 to 1.2.7 source, -p ignores -T and always queries over TCP. With 111/tcp closed and 111/udp open, which is exactly the state used for reflection, the command fails and the problem looks fixed. Test UDP with rpcinfo -u or nmap -sU.
ResultMeaning
111/tcp closed or filteredFixed for TCP
111/udp closedFixed: nothing listens, or the firewall rejects
111/udp open|filteredNo answer came back, the expected result with a DROP rule; confirm with rpcinfo -u
111/udp open, service rpcbindStill exposed
rpcinfo -u: program 100000 version 2 ready and waitingStill exposed: 111/udp answers, and that is the side used for reflection
rpcinfo -u ends with an RPC error, usually Timed out (after about a minute) or Unable to receive; the exact text varies by versionFixed for UDP
rpcinfo -p prints a program listStill exposed (TCP)
rpcinfo -p: RPC: Remote system error - Connection timed out, or Connection refusedFixed for TCP
Repeat the test after the next reboot, because that is when a service that was only disabled comes back.

6. What to put in your reply to the CERT or abuse report​

If your provider forwarded the notice, answer through its channel and within its deadline. If a CERT wrote to you directly, follow the instructions in the notice. Give the affected IPv4 and IPv6 addresses, the cause, the fix with a UTC time, the external verification and what prevents a repeat. The BSI says CERT-Bund reports are digitally signed. If an e-mail looks suspicious, test your IP yourself instead of following its links.
Code:
Subject: Re: <ticket or report number> open portmapper on 203.0.113.25

Hello,

The finding is confirmed and fixed.

Host: 203.0.113.25 (IPv6 2001:db8::25)
Cause: rpcbind was installed as a dependency of the NFS client tools and
listened on 111/tcp and 111/udp. The server does not use NFS or NIS.
Fix (2026-10-27 09:40 UTC): rpcbind.socket and rpcbind.service stopped
and masked; 111/tcp and 111/udp blocked in the host firewall (IPv4 and
IPv6) and in the provider's network firewall.
Verification (2026-10-27 09:55 UTC, from an external host):
"rpcinfo -u 203.0.113.25 100000 2" (UDP) and "rpcinfo -p 203.0.113.25"
(TCP) get no answer; nmap reports 111/tcp filtered and 111/udp
open|filtered with no RPC reply, on both the IPv4 and the IPv6 address.
Prevention: port 111 is now part of our weekly external port check.

Regards,
<name, company, contact>

7. Prevention: minimal installs and external scans​

Minimal installs. Start from a minimal image and install NFS client tools only where NFS is mounted. After provisioning, and after adding packages, compare ss -tulpn with the services you expect.

Default-deny on two layers. The host firewall and the provider firewall should each list only the ports you serve, and configuration management should keep rpcbind masked on rebuilt servers.

Scan your servers from outside, on a schedule, from a host in another network:
Bash:
#!/bin/sh
# /usr/local/bin/check-portmapper.sh, run from a host OUTSIDE your network
# crontab: 0 6 * * 1 /usr/local/bin/check-portmapper.sh
# IPv6 addresses: add the nmap -6 check from section 5 to the same schedule
for ip in 203.0.113.25 203.0.113.26; do
  if timeout 30 rpcinfo -u "$ip" 100000 2 >/dev/null 2>&1; then
    echo "ALERT: portmapper answers on $ip over 111/udp"
  fi
  if timeout 30 rpcinfo -p "$ip" >/dev/null 2>&1; then
    echo "ALERT: portmapper answers on $ip over 111/tcp"
  fi
done
Cron mails the output when local mail works; otherwise pipe it to your alerting. If you control an ASN or netblocks, you can subscribe to the free daily reports Shadowserver sends to network owners. Check the other UDP reflectors in CISA's list as well, such as NTP (123/udp), SNMP (161/udp), SSDP (1900/udp) and Memcached (11211/udp).

Troubleshooting​

SymptomLikely causeFix
"Warning: Stopping rpcbind.service, but it can still be activated by: rpcbind.socket" (systemd 254 and older) or "Stopping 'rpcbind.service', but its triggering units are still active: rpcbind.socket" (systemd 255 and newer)Only the service was stoppedDisable and mask rpcbind.socket as well
Port 111 is back after a reboot or a package reinstallDisabled, not masked: nfs-server, rpc-statd or an NFSv3 mount pulled rpcbind.socket in, or a reinstall enabled it againMask both units (the mask lives in /etc/systemd/system and updates leave it alone); check systemctl list-dependencies --reverse rpcbind.socket
Everything is masked, yet something still listens on 111Another process, for example a container that runs its own rpcbind with host networking, or docker-proxy for a container that publishes port 111Read the process column of ss -tulpn and deal with that service
mount.nfs: rpc.statd is not running but is required for remote lockingThe host mounts an NFSv3 shareMount with vers=4.2 if the server supports it; otherwise unmask, keep rpcbind and follow 3c
Clients cannot mount after the NFSv4-only changeThey ask for NFSv3, or a script relies on showmount -eUse vers=4.2 or 4.1 on the clients; check /proc/fs/nfsd/versions on the server
111 is in no CSF list but still openTESTING = "1" flushes the rules a few minutes after each start; IPV6 = "0"; csf is stopped, or never started because firewalld is activeSet TESTING = "0" (and IPV6 = "1" if the server has IPv6), stop and disable firewalld, run csf -ra

FAQ​

Is it safe to turn rpcbind off on a web or mail server?
Usually, yes. A typical web, mail or database stack does not use ONC RPC. The exceptions are NFSv3 mounts (backups to an NFS share are a common case), NIS logins and the rare legacy tool that registers with rpcbind; the checks in section 2 reveal all three.

Does NFSv4 need port 111?
No. NFSv4 uses TCP 2049 and handles locking inside the protocol. rpcbind is needed for NFSv2 and NFSv3 with their helpers (mountd, statd, lockd), and for NIS.

Isn't a firewall rule enough?
It closes the hole, and on an NFSv3 host it is the main control. But rule sets do get emptied or lost: CSF's test mode flushes them, and an iptables rule nobody saved disappears at the next reboot. Masking removes the listener, so a firewall slip does not bring the problem back.

The notice only mentions IPv4. Do I need to care about IPv6?
Yes. The BSI's FAQ describes scans of IPv4 addresses, so an IPv6 exposure may never show up in a report. rpcbind.socket still listens on [::]:111 by default, and an IPv4-only rule (iptables without ip6tables, or CSF with IPV6 = "0") leaves that open.

When do the notices stop?
According to the BSI's FAQ, no notification with a later timestamp should arrive once the problem is fixed. A notice that arrives after your fix but carries a timestamp from before it reflects an older scan. One with a later timestamp means the port is still reachable somewhere, perhaps on another of your IPs.

Conclusion and next steps​

An open portmapper is a short fix, and the common mistakes are predictable: rpcbind gets disabled but not masked, IPv4 gets closed while IPv6 stays open, or the UDP side is "verified" with rpcinfo -p, which only tests TCP. Find what uses rpcbind and mask it if nothing does, or move NFS to NFSv4-only. Restrict 111 in the firewall you actually run, test TCP and UDP from outside over both IP versions, and answer the report with times and evidence. Next, schedule the external check and work through the wider baseline in Server hardening in 2026: minimum viable security for production Linux and Server hardening for production teams: defence in depth, without paranoia. If you would rather hand this to a team, AIOR's cybersecurity, backup and data protection services include server hardening and port security. Questions about your own distribution or control panel are welcome in this thread.
 
Last edited:

Forum statistics

Threads
925
Messages
932
Members
26
Latest member
Jessicawatson

Members online

No members online now.

Featured content

AIOR
AIOR TECHNOLOGY

Get a quote for all your needs

Hosting · Domain · Servers · Design · Software · Engineering · Industry Solutions

Get a quote

24/7 Support · Quick response

Back
Top