Suse 11.0 nfsserver 配置固定端口

  最新公司要搬家,防火牆規則更改,需要我們提供固定的IP,協議以及端口,以便建立防火牆規則。

系統環境:

OS 版本:

xx-xx-patch:~ # cat /etc/SuSE-release
SUSE Linux Enterprise Desktop 11 (i586)
VERSION = 11
PATCHLEVEL = 0

 nfs 版本:

bj-ct-patch:~ # nfsstat -v
Server packet stats:
packets    udp        tcp        tcpconn
1139       0          1135       21
Server rpc stats:
calls      badcalls   badauth    badclnt    xdrcall
1136       0          0          0          0
Server reply cache:
hits       misses     nocache
0          0          1136
Server file handle cache:
lookup     anon       ncachedir  ncachedir  stale
0          0          0          0          0
Server nfs v3:##此處即爲nfs 的版本


nfsserver 端默認的固定端口只有兩個:111,2049,其他的默認都是隨機調用1024以上閒置端口。

NFS 可以看做是這個五個服務構成:

portmapper
nfsd
mountd
lockd
statd

在nfsserver 登錄後, 切換成root 或者運行 sudo rpcinfo -p, 即可查看相應的服務端口狀態(這個是更改過後的)。

xx-xx-patch:~ # rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  52553  status
    100024    1   tcp  42529  status
    100021    1   udp   2052  nlockmgr
    100021    4   tcp   2052  nlockmgr
    100007    2   udp    941  ypbind #這個不屬於nfs,是NIS client
    100005    3   udp   2050  mountd
    100005    3   tcp   2050  mountd
    100003    2   udp   2049  nfs
    100003    2   tcp   2049  nfs

   由於我們開發機版本比較詭異,在suse 官方文檔中找不到現成可用的方法,借鑑suse 官方文檔,經過嘗試以後,完成了mountd 以及nolckmgr 的端口設定,status 依舊沒有實現固定端口。

方法如下:

1. moutd, 重啓服務nfsserver 後生效。

xx-xx-patch:~ # vi /etc/sysconfig/nfs #打開這個文件,找到MOUNTD_PORT並設置端口值
#  Only set this if you want to start mountd on a fixed
#  port instead of the port assigned by rpc. Only for use
#  to export nfs-filesystems through firewalls.
#
MOUNTD_PORT="2050"

2.nlockmgr(注意, 這一步需要reboot才能生效)

xx-xx-patch:~ # ls /etc/modprobe.d/lockd #查看這個文件是否存在,不存在就創建。
/etc/modprobe.d/lockd
bj-ct-patch:~ # cat /etc/modprobe.d/lockd # 文件內容主需要更改成自己想要設置的端口即可。
#This file is created for the static port for locked, should work on SUSE 11.0
options lockd nlm_udpport=2052 nlm_tcpport=2052

3. status,雖然failed, 還是把方法share一下,萬一有成功的呢...

xx-xx-patch:~ # vi /etc/init.d/nfsserver 
#找到該文件/etc/init.d/nfsserver並打開。
#在文件裏找到如下內容的行,加上-p2051,2051 請更改成自己想要的端口號。
  # rpc.statd
      #Add -p2051 for the static port as BTP firewall rule on 24th,Nov 2016
      echo -n " statd"
      startproc /usr/sbin/rpc.statd --no-notify -p2051 || {
          rc_status -v
          rc_exit
      }


最後給出suse 官方文檔鏈接:

From <https://www.novell.com/support/kb/doc.php?id=7000524>  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章