[root@localhost tedu]# hostname nfsserver
[root@localhost tedu]# exit
exit
[tedu@localhost ~]$ su
Password:
[root@nfsserver tedu]# yum install -y nfs-utils rpcbind
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirror.lzu.edu.cn
* updates: mirrors.163.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Package rpcbind-0.2.0-16.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.2.3-78.el6 will be updated
---> Package nfs-utils.x86_64 1:1.2.3-78.el6_10.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
nfs-utils x86_64 1:1.2.3-78.el6_10.1 updates 337 k
Transaction Summary
================================================================================
Upgrade 1 Package(s)
Total download size: 337 k
Downloading Packages:
nfs-utils-1.2.3-78.el6_10.1.x86_64.rpm | 337 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : 1:nfs-utils-1.2.3-78.el6_10.1.x86_64 1/2
Cleanup : 1:nfs-utils-1.2.3-78.el6.x86_64 2/2
Verifying : 1:nfs-utils-1.2.3-78.el6_10.1.x86_64 1/2
Verifying : 1:nfs-utils-1.2.3-78.el6.x86_64 2/2
Updated:
nfs-utils.x86_64 1:1.2.3-78.el6_10.1
Complete!
[root@nfsserver tedu]# yum install -y nmap tree lrszs
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
Package tree-1.5.3-3.el6.x86_64 already installed and latest version
No package lrszs available.
Resolving Dependencies
--> Running transaction check
---> Package nmap.x86_64 2:5.51-6.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
nmap x86_64 2:5.51-6.el6 base 2.8 M
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 2.8 M
Installed size: 9.7 M
Downloading Packages:
nmap-5.51-6.el6.x86_64.rpm | 2.8 MB 00:08
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:nmap-5.51-6.el6.x86_64 1/1
Verifying : 2:nmap-5.51-6.el6.x86_64 1/1
Installed:
nmap.x86_64 2:5.51-6.el6
Complete!
[root@nfsserver tedu]# /etc/init.d/rpcbind start
[root@nfsserver tedu]# /etc/init.d/rpcbind status
rpcbind (pid 1520) is running...
[root@nfsserver tedu]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[
[root@nfsserver tedu]# chkconfig rpcbind on
[root@nfsserver tedu]# chkconfig nfs on
[root@nfsserver tedu]# ls /etc/rc.d/rc3.d/ |grep -E "nfs|rpc"
K61nfs-rdma
K69rpcsvcgssd
S13rpcbind
S24nfslock
S24rpcgssd
S30nfs
[root@nfsserver tedu]# chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@nfsserver tedu]# chkconfig --list nfs
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@nfsserver tedu]# rpm -aq nfs-utils rpcbind portmap
rpcbind-0.2.0-16.el6.x86_64
nfs-utils-1.2.3-78.el6_10.1.x86_64
[root@nfsserver tedu]# /etc/init.d/rpcbind restart
Stopping rpcbind: [ OK ]
Starting rpcbind: [ OK ]
[root@nfsserver tedu]# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
[root@nfsserver tedu]# more /etc/init.d/nfs
#!/bin/sh
#
# nfs This shell script takes care of starting and stopping
# the NFS services.
#
# chkconfig: - 30 60
# description: NFS is a popular protocol for file sharing across networks.
# This service provides NFS server functionality, which is \
# configured via the /etc/exports file.
# probe: true
# config: /etc/sysconfig/nfs
### BEGIN INIT INFO
# Provides: nfs
# Required-Start: $local_fs $network $syslog $rpcbind
# Required-Stop: $local_fs $network $syslog $rpcbind
# Default-Stop: 0 1 6
# Short-Description: Start up the NFS server sevice
# Description: NFS is a popular protocol for file sharing across networks \
# This service provides NFS server functionality, \
# which is configured via the /etc/exports file.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
# Check for and source configuration file otherwise set defaults
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
# Remote quota server
[ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad`
RETVAL=0
uid=`id | cut -d\( -f1 | cut -d= -f2`
# See how we were called.
case "$1" in
start)
# Check that networking is up.
[ "${NETWORKING}" != "yes" ] && exit 6
[ -x /usr/sbin/rpc.nfsd ] || exit 5
[ -x /usr/sbin/rpc.mountd ] || exit 5
[ -x /usr/sbin/exportfs ] || exit 5
# Make sure the rpc.mountd is not already running.
if status rpc.mountd > /dev/null ; then
exit 0
fi
# Only root can start the service
[ $uid -ne 0 ] && exit 4
# Don't fail if /etc/exports doesn't exist; create a bare-bones
# version and continue.
[ -r /etc/exports ] || \
{ touch /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
{ echo "/etc/exports does not exist" ; exit 0 ; }
[ -z "$MOUNTD_NFS_V2" ] && MOUNTD_NFS_V2=default
[ -z "$MOUNTD_NFS_V3" ] && MOUNTD_NFS_V3=default
# Number of servers to be started by default
[ -z "$RPCNFSDCOUNT" ] && RPCNFSDCOUNT=8
# Start daemons.
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd start
# Set the ports lockd should listen on
if [ -n "$LOCKD_TCPPORT" -o -n "$LOCKD_UDPPORT" ]; then
[ -x /sbin/modprobe ] && /sbin/modprobe lockd $LOCKDARG
[ -n "$LOCKD_TCPPORT" ] && \
/sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/
null 2>&1
[ -n "$LOCKD_UDPPORT" ] && \
/sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/
null 2>&1
fi
[ -n "$NLM_GRACE_PERIOD" ] && {
/sbin/sysctl -w fs.nfs.nlm_grace_period=$NLM_GRACE_PERIOD >/dev/
null 2>&1
}
# Load the nfsd module so /proc/fs/nfsd will exist
[ "$NFSD_MODULE" != "noload" -a -x /sbin/modprobe ] && {
/sbin/modprobe nfsd
[ -n "$RDMA_PORT" ] && /sbin/modprobe svcrdma
}
# Set v4 grace period if requested
[ -n "$NFSD_V4_GRACE" ] && {
echo "$NFSD_V4_GRACE" > /proc/fs/nfsd/nfsv4gracetime
}
# Set v4 lease period if requested
[ -n "$NFSD_V4_LEASE" ] && {
echo "$NFSD_V4_LEASE" > /proc/fs/nfsd/nfsv4leasetime
}
action $"Starting NFS services: " /usr/sbin/exportfs -r
if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
echo -n $"Starting NFS quotas: "
[ -n "$RQUOTAD_PORT" ] \
&& RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
daemon rpc.rquotad $RPCRQUOTADOPTS
touch /var/lock/subsys/rpc.rquotad
RETVAL=$?
echo
fi
[ -n "$MOUNTD_PORT" ] \
&& RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
case $MOUNTD_NFS_V1 in
no|NO)
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 1" ;;
esac
case $MOUNTD_NFS_V2 in
no|NO)
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 2" ;;
esac
case $MOUNTD_NFS_V3 in
no|NO)
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3" ;;
esac
echo -n $"Starting NFS mountd: "
daemon rpc.mountd $RPCMOUNTDOPTS
RETVAL=$?
echo
touch /var/lock/subsys/rpc.mountd
touch /var/lock/subsys/nfs
echo -n $"Starting NFS daemon: "
daemon rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT
RETVAL=$?
echo
[ $RETVAL -ne 0 ] && exit $RETVAL
[ -n "$RDMA_PORT" ] && echo "rdma $RDMA_PORT" > /proc/fs/nfsd/portlist
# Let's if we need to signal or start rpc.idmapd
if [ -f /var/lock/subsys/rpc.idmapd ]; then
killproc rpc.idmapd -1 # SIGHUP
else
/sbin/service rpcidmapd start
touch /var/lock/subsys/nfs-rpcidmapd
fi
;;
stop)
# Only root can stop the service
[ $uid -ne 0 ] && exit 4
# Stop daemons.
echo -n $"Shutting down NFS daemon: "
killproc nfsd -2
RETVAL=$?
echo
echo -n $"Shutting down NFS mountd: "
killproc rpc.mountd
rval=$?
[ $RETVAL -eq 0 ] && RETVAL=$rval
echo
if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
echo -n $"Shutting down NFS quotas: "
killproc rpc.rquotad
rval=$?
[ $RETVAL -eq 0 ] && RETVAL=$rval
echo
fi
# Reset the lockd ports if they were set
if [ -n "$LOCKD_TCPPORT" ]; then
/sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
fi
if [ -n "$LOCKD_UDPPORT" ]; then
/sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
fi
if [ -n "$NLM_GRACE_PERIOD" ]; then
/sbin/sysctl -w fs.nfs.nlm_grace_period=0 >/dev/null 2>&1
fi
# Do it the last so that clients can still access the server
# when the server is running.
cnt=`/usr/sbin/exportfs -v | /usr/bin/wc -l`
if [ $cnt -gt 0 ]; then
action $"Shutting down NFS services: " /usr/sbin/exportfs -au
rval=$?
[ $RETVAL -eq 0 ] && RETVAL=$rval
fi
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd stop
[ -f /var/lock/subsys/nfs-rpcidmapd ] && /sbin/service rpcidmapd stop
rm -f /var/lock/subsys/nfs
rm -f /var/lock/subsys/nfs-rpcidmapd
rm -f /var/lock/subsys/rpc.mountd
rm -f /var/lock/subsys/rpc.rquotad
;;
status)
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd status
status rpc.mountd
RETVAL=$?
status -l nfs nfsd
rval=$?
[ $RETVAL -eq 0 ] && RETVAL=$rval
if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
status rpc.rquotad
rval=$?
[ $RETVAL -eq 0 ] && RETVAL=$rval
fi
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
reload | force-reload)
/usr/sbin/exportfs -r
[ -f /var/lock/subsys/nfs ] && touch /var/lock/subsys/nfs
;;
probe)
if [ ! -f /var/lock/subsys/nfs ] ; then
echo $"start"; exit 0
fi
/sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
/sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
echo $"restart"; exit 0
fi
if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
echo $"reload"; exit 0
fi
;;
condrestart | try-restart)
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condrestart
[ -f /var/lock/subsys/nfs ] && {
$0 stop
$0 start
RETVAL=$?
}
;;
condstop)
[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condstop
[ -f /var/lock/subsys/nfs ] && {
$0 stop
RETVAL=$?
}
;;
*)
echo $"Usage: nfs {start|stop|status|restart|reload|force-reload|condres
tart|try-restart|condstop}"
RETVAL=2
;;
esac
exit $RETVAL
[root@nfsserver tedu]# cat /etc/exports
[root@nfsserver tedu]# mkdir /data
[root@nfsserver tedu]# ll /data
total 0
[root@nfsserver tedu]# ls
Desktop Downloads Music Public Videos
Documents mbr.bin Pictures Templates
[root@nfsserver tedu]# cp mbr.bin /data
[root@nfsserver tedu]# ll /data
total 4
-rw-r--r--. 1 root root 512 Feb 12 16:08 mbr.bin
[root@nfsserver tedu]# vi /etc/exports
#shared data for bbs by tedu at 20190212
#shared data for bbs by tedu at 20190212
"/etc/exports" 2L, 74C written
[root@nfsserver tedu]# cat /etc/exports
#shared data for bbs by tedu at 20190212
/data 192.168.19.132/24(rw,sync)
[root@nfsserver tedu]# /etc/init.d/nfs reload
[root@nfsserver tedu]# vi /etc/init.d/nfs
#!/bin/sh
#
# nfs This shell script takes care of starting and stopping
# the NFS services.
#
# chkconfig: - 30 60
# description: NFS is a popular protocol for file sharing across networks.
# This service provides NFS server functionality, which is \
# configured via the /etc/exports file.
# probe: true
# config: /etc/sysconfig/nfs
### BEGIN INIT INFO
# Provides: nfs
# Required-Start: $local_fs $network $syslog $rpcbind
# Required-Stop: $local_fs $network $syslog $rpcbind
# Default-Stop: 0 1 6
# Short-Description: Start up the NFS server sevice
# Description: NFS is a popular protocol for file sharing across networks \
# This service provides NFS server functionality, \
# which is configured via the /etc/exports file.
;;
;;
;;
[root@nfsserver tedu]# showmount -e localhost
clnt_create: RPC: Program not registered
[root@nfsserver tedu]# /etc/init.d/rpcbind start
[root@nfsserver tedu]# /etc/init.d/rpcbind status
rpcbind (pid 5390) is running...
[root@nfsserver tedu]# showmount -e localhost
clnt_create: RPC: Program not registered
[root@nfsserver tedu]# /etc/init.d/nfs stop
/etc/init.d/rpcbind stopShutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Shutting down RPC idmapd: [ OK ]
[root@nfsserver tedu]#
[root@nfsserver tedu]# /etc/init.d/rpcbind stop
Stopping rpcbind: [ OK ]
[root@nfsserver tedu]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[root@nfsserver tedu]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[root@nfsserver tedu]# showmount -e localhost
Export list for localhost:
/data 192.168.19.132/24
[root@nfsserver tedu]# iptables -A INPUT -p tcp -s 192.168..19.132 -j ACCEPT
iptables v1.4.7: host/network `192.168..19.132' not found
Try `iptables -h' or 'iptables --help' for more information.
[root@nfsserver tedu]# iptables -A INPUT -p tcp -s 192.168.19.132 -j ACCEPT
[root@nfsserver tedu]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@nfsserver tedu]# rz
rz waiting to receive.
zmodem trl+C ȡ
100% 18 KB 18 KB/s 00:00:01 0 Errors
100% 218 bytes 218 bytes/s 00:00:01 0 Errors
100% 233 bytes 233 bytes/s 00:00:01 0 Errors
100% 23426 KB 11713 KB/s 00:00:02 0 Errors
[root@nfsserver tedu]# ll /data
total 4
-rw-r--r--. 1 root root 512 Feb 12 16:08 mbr.bin
[root@nfsserver tedu]# ls -ld /data
drwxr-xr-x. 2 root root 4096 Feb 12 16:08 /data
[root@nfsserver tedu]# ls -l /data
total 4
-rw-r--r--. 1 root root 512 Feb 12 16:08 mbr.bin
[root@nfsserver tedu]# cd /data
[root@nfsserver data]# la
bash: la: command not found
[root@nfsserver data]# ls
mbr.bin
[root@nfsserver data]# ls -a
. .. mbr.bin
[root@nfsserver data]# cd ..
[root@nfsserver /]# ls
bin data etc lib lost+found misc net proc sbin srv tmp var
boot dev home lib64 media mnt opt root selinux sys usr
[root@nfsserver /]# cd /home/tedu
[root@nfsserver tedu]# ls
Desktop Music 渗透测试全套教程(从原理到实战).zip
Documents Pictures 网络安全渗透思路.rar
Downloads Public 黑麒麟2018渗透培训系列教程-实战渗透篇.rar
Downloads.rar Templates
mbr.bin Videos
[root@nfsserver tedu]# cp Downloads.rar /data
[root@nfsserver tedu]# cp 渗透测试全套教程\(从原理到实战\).zip /data
[root@nfsserver tedu]# cp 网络安全渗透思路.rar /data
[root@nfsserver tedu]# cp 黑麒麟2018渗透培训系列教程-实战渗透篇.rar /data
[root@nfsserver tedu]# cd /data
[root@nfsserver data]# la
bash: la: command not found
[root@nfsserver data]# ls
Downloads.rar 网络安全渗透思路.rar
mbr.bin 黑麒麟2018渗透培训系列教程-实战渗透篇.rar
渗透测试全套教程(从原理到实战).zip
[root@nfsserver data]#
[root@nfsserver data]# ls -l
total 23460
-rw-r--r--. 1 root root 18810 Feb 12 17:44 Downloads.rar
-rw-r--r--. 1 root root 512 Feb 12 16:08 mbr.bin
-rw-r--r--. 1 root root 233 Feb 12 17:45 渗透测试全套教程(从原理到实战).zip
-rw-r--r--. 1 root root 23988797 Feb 12 17:45 网络安全渗透思路.rar
-rw-r--r--. 1 root root 218 Feb 12 17:46 黑麒麟2018渗透培训系列教程-实战渗透篇.rar
[root@nfsserver data]# rm -f mbr.bin
[root@nfsserver data]#
[root@nfsserver data]# ls -l
total 23456
-rw-r--r--. 1 nfsnobody nfsnobody 18810 Feb 12 17:44 Downloads.rar
-rw-r--r--. 1 nfsnobody nfsnobody 0 Feb 12 19:49 tedu.log
-rw-r--r--. 1 nfsnobody nfsnobody 233 Feb 12 17:45 渗透测试全套教程(从原理到实战).zip
-rw-r--r--. 1 nfsnobody nfsnobody 23988797 Feb 12 17:45 网络安全渗透思路.rar
-rw-r--r--. 1 nfsnobody nfsnobody 218 Feb 12 17:46 黑麒麟2018渗透培训系列教程-实战渗透篇.rar
[root@nfsserver data]# ls -l
total 23436
-rw-r--r--. 1 nfsnobody nfsnobody 0 Feb 12 19:49 tedu.log
-rw-r--r--. 1 nfsnobody nfsnobody 233 Feb 12 17:45 渗透测试全套教程(从原理到实战).zip
-rw-r--r--. 1 nfsnobody nfsnobody 23988797 Feb 12 17:45 网络安全渗透思路.rar
-rw-r--r--. 1 nfsnobody nfsnobody 218 Feb 12 17:46 黑麒麟2018渗透培训系列教程-实战渗透篇.rar
[root@nfsserver data]# yum install telnet-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.x86_64 1:0.17-48.el6 will be installed
--> Processing Dependency: xinetd for package: 1:telnet-server-0.17-48.el6.x86_64
--> Running transaction check
---> Package xinetd.x86_64 2:2.3.14-40.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
telnet-server x86_64 1:0.17-48.el6 base 37 k
Installing for dependencies:
xinetd x86_64 2:2.3.14-40.el6 base 122 k
Transaction Summary
================================================================================
Install 2 Package(s)
Total download size: 159 k
Installed size: 313 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): telnet-server-0.17-48.el6.x86_64.rpm | 37 kB 00:00
(2/2): xinetd-2.3.14-40.el6.x86_64.rpm | 122 kB 00:00
--------------------------------------------------------------------------------
Total 331 kB/s | 159 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:xinetd-2.3.14-40.el6.x86_64 1/2
Installing : 1:telnet-server-0.17-48.el6.x86_64 2/2
Verifying : 1:telnet-server-0.17-48.el6.x86_64 1/2
Verifying : 2:xinetd-2.3.14-40.el6.x86_64 2/2
Installed:
telnet-server.x86_64 1:0.17-48.el6
Dependency Installed:
xinetd.x86_64 2:2.3.14-40.el6
Complete!