This might have been posted before but I couldn't find an all inclusive thread, so here is mine. I am no expert with NFS since I just got it working. I don't have a 2.4x boxen around so I can't post the kernel selections.
SERVER
Make sure that you have the support within your kernel:
Code: Select all
# cd /usr/src/linux
# make menuconfig
File systems --->
Network File Systems --->
<*> NFS file system support
[*] Provide NFSv3 client support
[ ] Provide NFSv4 client support (EXPERIMENTAL)
[ ] Allow direct I/O on NFS files (EXPERIMENTAL)
<*> NFS server support
[*] Provide NFSv3 server support
[ ] Provide NFSv4 server support (EXPERIMENTAL)
[*] Provide NFS server over TCP support (EXPERIMENTAL)
Code: Select all
# make && make modules_install
# mount /boot/
# cp arch/i386/boot/bzImage /boot/kernel-2.6.7
Emerge NFS:
Code: Select all
# emerge -v nfs-utilsCode: Select all
# nano /etc/exports
# /etc/exports: NFS file systems being exported. See exports(5).
/storage 192.168.0.5(rw)
http://nfs.sourceforge.net/nfs-howto/server.html
Portmap is required for NFS:
Code: Select all
# /etc/init.d/portmap start
# rc-update add portmap default
Code: Select all
# /etc/init.d/nfs start
# rc-update add nfs default
Code: Select all
# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32771 status
100024 1 tcp 32771 status
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100021 1 udp 32772 nlockmgr
100021 3 udp 32772 nlockmgr
100021 4 udp 32772 nlockmgr
100021 1 tcp 32772 nlockmgr
100021 3 tcp 32772 nlockmgr
100021 4 tcp 32772 nlockmgr
100005 1 udp 797 mountd
100005 1 tcp 800 mountd
100005 2 udp 797 mountd
100005 2 tcp 800 mountd
100005 3 udp 797 mountd
100005 3 tcp 800 mountd
Code: Select all
# exportfs -ra
# /etc/init.d/nfs restart
Make sure that you have the support within your kernel:
Code: Select all
# cd /usr/src/linux
# make menuconfig
File systems --->
Network File Systems --->
<*> NFS file system support
[*] Provide NFSv3 client support
[ ] Provide NFSv4 client support (EXPERIMENTAL)
[ ] Allow direct I/O on NFS files (EXPERIMENTAL)
Code: Select all
# make && make modules_install
# mount /boot/
# cp arch/i386/boot/bzImage /boot/kernel-2.6.7
Emerge NFS:
Code: Select all
# emerge -v nfs-utilsCode: Select all
# /etc/init.d/portmap start
# rc-update add portmap default
Code: Select all
# /etc/init.d/nfs start
# rc-update add nfs default
Code: Select all
# mount 192.168.0.2:/storage /mnt/nfs
http://nfs.sourceforge.net/nfs-howto/client.html
ADDITION:
NFS and iptables
If you want to use iptables along with your nfs server please follow these directions:
Code: Select all
# emerge iptables
# cd /usr/src/linux; make menuconfig
-Device Drivers
-Networking Support
-Networking Options
-[*] Network packet filtering
-IP: Netfilter Configuration
NOTE: Change all [*] to [M] in Netfilter Configuration
# make && make modules_install
# mount /boot
# cp arch/i386/boot/bzImage /boot/kernel
# nano /etc/conf.d/nfs
# Options to pass to rpc.mountd
# ex. RPCMOUNTDOPTS="-p 32767
RPCMOUNTDOPTS="-p 4002"
# Options to pass to rpc.statd
# ex. RPCSTATDOPTS="-p 32765 -o 32766"
RPCSTATDOPTS="-p 4000"
# nano /etc/modules/autoload/kernel
ip_tables
# reboot
Code: Select all
# nano /sbin/firewall
-- start script --
#!/bin/bash
# script variables
IPTABLES='/sbin/iptables' # iptables executable
# Flush all chains
$IPTABLES --flush
# Allow unlimited traffic on the loopback interface
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT
# Set default policies
$IPTABLES --policy INPUT DROP
$IPTABLES --policy OUTPUT DROP
$IPTABLES --policy FORWARD DROP
# Previously initiated and accepted exchanges bypass rule checking
# Allow unlimited outbound traffic
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# Allow ICMP ECHO REQUESTS from anywhere
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
# for SSH server
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
# for NFS server
$IPTABLES -A INPUT -p tcp -m tcp -s --dport 111 -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp -s --dport 2049 -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp -s --dport 4000 -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp -s --dport 4001 -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp -s --dport 4002 -j ACCEPT
$IPTABLES -A INPUT -p udp -m udp -s --dport 111 -j ACCEPT
$IPTABLES -A INPUT -p udp -m udp -s --dport 2049 -j ACCEPT
$IPTABLES -A INPUT -p udp -m udp -s --dport 4000 -j ACCEPT
$IPTABLES -A INPUT -p udp -m udp -s --dport 4001 -j ACCEPT
$IPTABLES -A INPUT -p udp -m udp -s --dport 4002 -j ACCEPT
# Drop all other traffic
$IPTABLES -A INPUT -j DROP
-- end script --
# chmod 700 /sbin/firewall
# nano /etc/conf.d/local.start
/sbin/firewall (I know it's a hack so sue me)







