nfs穿透NAT挂载

1. 为什么要NAT?1. 为什么要NAT?

虚拟机母鸡用的wifi,无法使用桥接模式,母鸡也不支持路由,所以如果要在raspberryPi上挂载虚拟机中的nfs文件系统则必须透过nat来使用。

2. 查看nfs使用的端口

nfs使用的端口可以通过rpcinfo看到
[root@K /usr/home/chk]# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 rpcbind
100000 3 tcp 111 rpcbind
100000 2 tcp 111 rpcbind
100000 4 udp 111 rpcbind
100000 3 udp 111 rpcbind
100000 2 udp 111 rpcbind
100000 4 local 111 rpcbind
100000 3 local 111 rpcbind
100000 2 local 111 rpcbind
100005 1 udp 840 mountd
100005 3 udp 840 mountd
100005 1 tcp 840 mountd
100005 3 tcp 840 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
如上所示,因此需要在virtualbox中设置转发端口:
在这里插入图片描述

3. 设置mountd使用固定端口

在/etc/rc.conf中加入 mountd_flags="-r -l -n -p 840"
则指定mountd使用840端口

4. 设置允许的IP

/etc/exports中允许的IP需要改为母鸡的IP,因为nfs协议里不会包含nfs client的出口源IP,允许的IP为服务器实际收到IP包的源地址

5. 在客户机上查看

chk@J:~ % rpcinfo -s 192.168.2.154
program version(s) netid(s) service owner
100000 2,3,4 local,udp6,tcp6,udp,tcp rpcbind superuser
100005 3,1 tcp,udp,tcp6,udp6 mountd superuser
100003 3,2 tcp6,tcp,udp6,udp nfs superuser
chk@J:~ % showmount -e 192.168.2.154
Exports list on 192.168.2.154:
/usr/armobj 10.0.3.2
/usr/release-10 10.0.3.2
/usr/obj 10.0.3.2
chk@J:~ % mount
/dev/mmcsd0s2a on / (ufs, local, noatime, journaled soft-updates)
devfs on /dev (devfs, local)
192.168.2.154:/usr/release-10 on /usr/src (nfs)
192.168.2.154:/usr/armobj on /usr/obj (nfs)

6. mount好就可以直接在arm上编译系统了

http://blog.sina.com.cn/s/blog_a0aacb430101qv8c.html

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐