码迷,mamicode.com
首页 > 其他好文 > 详细

Suse 11.0 nfsserver 配置固定端口

时间:2016-11-24 19:38:54      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:linux   port   nfs   suse   firewall   

  最新公司要搬家,防火墙规则更改,需要我们提供固定的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>  

本文出自 “饮水思源” 博客,请务必保留此出处http://weichuankui.blog.51cto.com/7494019/1876178

Suse 11.0 nfsserver 配置固定端口

标签:linux   port   nfs   suse   firewall   

原文地址:http://weichuankui.blog.51cto.com/7494019/1876178

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!