OpenWrt Forum Archive

Topic: How to setup NFS Server?

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi!

I am running Attitude Adjustment on my TP-LINK 3020. My ISP runs a hotspot that I have to connect to and so my interfaces are setup like this: http://i.imgur.com/ldpdctT.png, wifi: http://i.imgur.com/w8xCEdh.png

I have usb setup and have automounted my USB disks with block-mount. I have also done pivot overlay method and now have 3 gigs of space for /overlay.

I want to run a NFS on the router. So I did the following:

1. Installed 'nfs-kernel-server unfs3'
2. vim /etc/exports

'/media 192.168.1.0/255.255.255.0(rw,sync,no_subtree_check)'

3. Ran:

/etc/init.d/portmap start
/etc/init.d/unfs3 start
/etc/init.d/portmap enable
/etc/init.d/unfs3 enable

Now I know that I must execute these commands (wiki.openwrt.org/doc/howto/nfs.server) but dont know what I must set NET_LAN and IF_LAN variables in the shell.

$IPT -A INPUT -j ACCEPT -i eth0.1 -s $NET_LAN -p tcp --dport 111
$IPT -A INPUT -j ACCEPT -i eth0.1 -s $NET_LAN -p udp --dport 111
$IPT -A INPUT -j ACCEPT -i eth0.1 -s $NET_LAN -p tcp --dport 32777:32780
$IPT -A INPUT -j ACCEPT -i eth0.1 -s $NET_LAN -p udp --dport 32777:32780
$IPT -t raw -A INPUT -i $IF_LAN -s $NET_LAN -p tcp --dport 32777:32780 -j CT --notrack
$IPT -t raw -A INPUT -i $IF_LAN -s $NET_LAN -p udp --dport 32777:32780 -j CT --notrack
$IPT -t raw -A OUTPUT -o $IF_LAN -d $NET_LAN -p tcp --dport 32777:32780 -j CT --notrack
$IPT -t raw -A OUTPUT -o $IF_LAN -d $NET_LAN -p udp --dport 32777:32780 -j CT --notrack

I also dont know how to connect to my NFS server from my computer running OSX.

Thanks for your help!

hi heres the vocabulary:)
http://ipset.netfilter.org/iptables.man.html

$IPT -t raw -A INPUT -i $IF_LAN -s $NET_LAN -p tcp --dport 32777:32780 -j CT --notrack

$IPT = iptables
-s, --source address[/mask][,...]
-i, --in-interface name
-t, --table table
-d, --destination address[/mask][,...]

Thank you!

This is my /etc/firewall.user file

root@OpenWrt:~# cat /etc/firewall.user
# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.
IPT=iptables
NET_LAN=192.168.1.0/24
IF_LAN=eth0

# portmap
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p tcp --dport 111
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p udp --dport 111

# nfsd
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p tcp --dport 32777:32780
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p udp --dport 32777:32780

This is my /etc/exports:

root@OpenWrt:~# cat /etc/exports
/overlay/mnt/ 192.168.1.18(rw,all_squash,async,no_subtree_check)

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    3.6G    127.9M      3.3G   4% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.3M    120.0K     14.1M   1% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                 3.6G    127.9M      3.3G   4% /overlay
overlayfs:/overlay        3.6G    127.9M      3.3G   4% /
/dev/sdb2               465.3G    311.3G    154.0G  67% /mnt/myhdd

I still cant connect to my NFS share dir, i get a permission denied error in OSX.

Hi!

Now am able to view files on my NFS USB share
These are my stats:

root@OpenWrt:/mnt/hdd# cat /etc/firewall.user
# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.
IPT=iptables
NET_LAN=192.168.1.0/24
IF_LAN=eth0

# portmap
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p tcp --dport 111
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p udp --dport 111

# nfsd
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p tcp --dport 32777:32780
$IPT -I INPUT -j ACCEPT -i $IF_LAN -s $NET_LAN -p udp --dport 32777:32780
root@OpenWrt:/mnt/hdd# cat /etc/config/fstab

config global 'automount'
    option from_fstab '1'
    option anon_mount '1'

config global 'autoswap'
    option from_fstab '1'
    option anon_swap '0'

config mount
    option device '/dev/sda1'
    option fstype 'ext4'
    option options 'rw,sync'
    option enabled '1'
    option target '/openwrt'
    option enabled_fsck '1'

config mount
    option device '/dev/sdb2'
    option fstype 'vfat'
    option enabled_fsck '1'
    option target '/mnt/hdd'
    option enabled '1'

config swap
    option enabled '0'
    option device '/dev/sdb1'

root@OpenWrt:/mnt/hdd# cat /etc/exports
/mnt/hdd *(rw,insecure,nohide,all_squash,async,no_subtree_check)

But am not able to write. Am running MacOSX Yosemite.
This is the last leg of the setup, any help is super appreciated smile
Thanks!

check permissions
for vfat i use this

option options 'umask=000,dmask=000,fmask=000,uid=65534,gid=65534'

hi! Thank you so much for the reply I was able to get writable NFS share. Though I have few more questions:

What do these options 'umask=000,dmask=000,fmask=000,uid=65534,gid=65534'  mean? Especially the uid and guid values? Are they constant? What do they represent?

Is it normal that I now see uid and gid like this:

➜  ~  ll /Volumes/hdd
total 320
drwxrwxrwx  4 65534  65534    32K Jul 26 23:24 Gucci Files
drwxrwxrwx  6 65534  65534    32K Jul 22 11:36 audio
drwxrwxrwx  9 65534  65534    32K Jun 14 14:56 playground
drwxrwxrwx  5 65534  65534    32K Jul 22 11:37 software
drwxrwxrwx  5 65534  65534    32K Jul 22 11:30 videos

also is my /etc/exports correct? I am using unfs3

/mnt/hdd 192.168.1.0/24(rw,fsid=root,no_subtree_check,all_squash,async,insecure)

Thanks very much!



P.S: For any who is looking at this via Google: instrcutions on How to setup NFS on their Openwrt is here https://gist.github.com/sindhus/f60a826b0e860fd3aa1a

sindhus wrote:

hi! Thank you so much for the reply I was able to get writable NFS share. Though I have few more questions:

What do these options 'umask=000,dmask=000,fmask=000,uid=65534,gid=65534'  mean? Especially the uid and guid values? Are they constant? What do they represent?

Is it normal that I now see uid and gid like this:

➜  ~  ll /Volumes/hdd
total 320
drwxrwxrwx  4 65534  65534    32K Jul 26 23:24 Gucci Files
drwxrwxrwx  6 65534  65534    32K Jul 22 11:36 audio
drwxrwxrwx  9 65534  65534    32K Jun 14 14:56 playground
drwxrwxrwx  5 65534  65534    32K Jul 22 11:37 software
drwxrwxrwx  5 65534  65534    32K Jul 22 11:30 videos

also is my /etc/exports correct? I am using unfs3

/mnt/hdd 192.168.1.0/24(rw,fsid=root,no_subtree_check,all_squash,async,insecure)

Thanks very much!



P.S: For any who is looking at this via Google: instrcutions on How to setup NFS on their Openwrt is here https://gist.github.com/sindhus/f60a826b0e860fd3aa1a

the shares are located on a fat32 partition
dont know what exactly do they mean(they mean user id; group id; user mask; directory mask; file mask - some very important stuff on linux but not applicable for vfat type of file system) but when i did my usb storage i found them on net
basically they bypass all linux file system security so if you have sensitive data dont use vfat filesystem unless your the only one that has access at that filesystem

they files stored like that have all permission on so they are executable by everybody

(Last edited by makarel on 13 Aug 2015, 17:22)

makarel wrote:

some very important stuff on linux but not applicable for vfat type of file system) but when i did my usb storage i found them on net
basically they bypass linux file system security

If they are not applicable to vfat type of filesystem, then why does putting it make a difference? (the difference being with those options on, I am able to write on the NFS share on my client and without I cant).

p.S; client is OSX and NFS server is Openwrt Attitude Adjustment.

sindhus wrote:

If they are not applicable to vfat type of filesystem, then why does putting it make a difference? (the difference being with those options on, I am able to write on the NFS share on my client and without I cant).

p.S; client is OSX and NFS server is Openwrt Attitude Adjustment.


vfat doesnt have linux like content permissions so when you mount vfat you have to establish a base file permission on which all vfat mounted will work

i chose to give all permissions..
you can set it otherwise

Ok thank you! smile

The discussion might have continued from here.