Ubuntu – NFS server setup: 192.168.1.0/24 vs 192.168.1.*

networkingnfsUbuntu

I have my nfs server running on 192.168.1.99 box, and I have my /etc/exports configured using

/myshare 192.168.1.*(rw,sync,no_subtree_check)

I was able to mount nfs from 192.168.1.50 client box.

However I was unable to mount from 192.168.1.49! ("mount.nfs mount(2) permission denied" followed by "mount.nfs access denied by server while mounting")

Then I found that I can make connection if I change client's ip to 192.168.1.48

Finally, I was able to make it work by using 192.168.1.0/24 instead of 192.168.1.*

Could anybody explain why 192.168.1.0/24 works for 192.168.1.49, but 192.168.1.* does not?

    netmask 255.255.255.0
    network 192.168.1.0

… I'm not an administrator, and I have weak understanding of subnets… Ubuntu64, 12.04…

Best Answer

Please refer to the manpage of exports(5):

Machine Name Formats
NFS clients may be specified in a number of ways:

[...]

IP networks
    You  can  also  export  directories  to  all hosts on an IP (sub-) network
    simultaneously. This is done by specifying an IP address and netmask  pair
    as  address/netmask  where  the netmask can be specified in dotted-decimal
    format,  or  as  a  contiguous   mask   length.    For   example,   either
    `/255.255.252.0'  or  `/22'  appended  to  the  network  base IPv4 address
    results in identical subnetworks with 10 bits of host. [...]
    Wildcard characters generally  do  not  work on IP addresses, though they
    may work by accident when reverse DNS lookups fail.

wildcards
    Machine names may contain the wildcard characters * and ?, or may  contain
    character  class lists within [square brackets].  This can be used to make
    the exports file more compact;  for  instance,  *.cs.foo.edu  matches  all
    hosts  in  the domain cs.foo.edu.  As these characters also match the dots
    in a domain name, the given pattern will also match all hosts  within  any
    subdomain of cs.foo.edu.

This simply means you're configuring it wrong in the line

/myshare 192.168.1.*(rw,sync,no_subtree_check)

Wildcards can be used in hostnames, for specifying IP networks, you need to use dotted-decimal IP addresses and an optional subnet size. The reverse IP-lookup story above could explain why it worked for a specific address.