Created at:



How to set up NFS and NIS

NetBSD wiki


Configure domainname in command line (domainname command) or in rc.conf:



Also, configure your /etc/hosts correctly.


    # ypinit -m

It will ask you about the server names. If you configured /etc/hosts correctly, the local machine name will appear there.

Add the following lines to rc.conf::


Start them::

    # /etc/rc.d/rpcbind start
    # /etc/rc.d/ypserv start
    # /etc/rc.d/ypbind start
    # /etc/rc.d/yppasswdd start

If ypbind hang up (see How to set up NFS and NIS_), Ctrl-C to return to the shell.

Make databases::

    # cd /var/yp
    # make

If it complains about ypbind not working, execute /etc/rc.d/ypbind start (it will probably not hang up at this time) and execute make again.

NetBSD mailing list message about that


On the client side, also set the domainname in rc.conf:


Initialize client configuration::

    # ypinit -c

It will ask for the NIS server. Add NIS IP address or name (if you have DNS).

Add the following lines to rc.conf::


Also, start these services::

    /etc/rc.d/rpcbind start
    /etc/rc.d/ypbind start

You can now change /etc/nsswitch.conf to configure NIS working correctly:


Replace the lines::

    group:      compat
    hosts:      files dns
    passwd:     compat


    group:      nis files
    hosts:      files dns nis
    passwd:     nis files

*Note*: Take a look that "nis" goes at the end of the line for the "hosts:" line. This is because I got a problem in Firefox (3.6.3) that, after running a few seconds, it started to find hosts by DNS. Simply putting "nis" at the end, make all work. Strange, but worked!


Count not find

    # make
    make: "/var/yp/Makefile" line 8: Could not find
    make: Fatal errors encountered -- cannot continue

Solution: You need to install comp.tgz set.

TODO: title here again

    # make
    make: "/etc/mk.conf" line 494: Malformed conditional (${OPSYS} == "IRIX")
    make: "/etc/mk.conf" line 494: Need an operator
    make: "/etc/mk.conf" line 506: Malformed conditional (${OPSYS} == "SunOS")
    make: "/etc/mk.conf" line 506: Need an operator
    make: "/usr/share/mk/" line 13: if-less endif
    make: "/usr/share/mk/" line 13: Need an operator
    make: Fatal errors encountered -- cannot continue

Solution: You don't need to cd /var/yp && make on clients.

Can ping external IPs, but the names are not resolved

Did you put the "dns" string in for "hosts:" in nsswitch.conf?

TODO: title here again 2

    $ ssh host
    Failed to add the host to the list of known hosts

    Solution: Not clear... but it seems that the host you are trying to
    connect from, have the "nis" word in the "passwd:" clause when it is not
    necessary. Try to use "passwd: compat" instead of "passwd: nis files".

    (In my case, I put "passwd: nis files" in a host that didn't needed that
    because user information was yet in the host, because these information
    was not migrated yet.)

TODO: title here again 3

    # /etc/rc.d/ypbind start
    ypbind[298]: direct: sendto: No route to host
    ypbind[298]: no contactable servers found in /var/yp/binding/renegado.ypservers

Solution: Not clear about the cause of this error, but I just took out interface logging in pf.conf, and everything turned ok.

I commented this line::

    # set loginterface ppp0

Other references