基于SAMBA+DHCP完成案例

@[TOC]SAMBA+DHCP实现课堂案例 1.配置多用户挂载 再服务器上通过SMB共享目录/devops,并满足以下要求 1)、共享名为devops 2)、共享目录devops只能被192.168.100.0/24网段中的客户端使用 3)、共享目录devops必须可以被浏览 browseable =Yes 4)、用户xixi必须能以读的方式访问此共享,访问密码是redhat 5)、用户heihei必须能以读写的方式访问此共享,访问密码是redhat 此共享永久挂载在192.168.171.144上的/devops/目录,并使用用户xixi作为认证任何用户可以通过用户heihei来临时获取写的权限 2.配置dhcp实现动态分配和手动分分配方式)

一、第一题

1.设置共享名为devops,文件可以被浏览,用户xixi必须能已读的方式访问,用户heihei必须能以读写的方式访问:记得第一步安装samba包哦 yum install samba -y

服务端

vim /etc/samba/smb.conf
[devops]
comment=rhdsfdsfhdskfhd
path=/devops
hosts allow = 172.24.8.----指定网关
browseable=Yes -----可浏览
read only = Yes -----全弄可读
write list = heihei -----只有heihei用户可以进行读写操作

2.设置文件资源:

#mkdir  /devops
#useradd heihei
#useradd xixi
#smbpasswd -a heihei -----添加到smb里
redhat ----设置密码为redhat
#smbpasswd -a xixi
redhat
#chmod o+w /devops ---可以直接给权限
也可以利用指定的方式给予权限 #setfacl -m u:heihei:rwx /devops
#systemctl smb nmb

客户端
(1)安装cifs-utlils (实现多用户挂载,通过cifscreds提权)

	#yum install cifs-utlis -y

(2)按照要求挂载:

#vim /etc/fstab ---实现永久挂载
//172.24.8.128/devops    /devops   cifs defualts,multiuser,username=xixi,password=redhat.sec=ntlmssp   0 0  ----实现永久挂载
#mkdir /devops
#mount -a

(3)创建测试用户:

#useradd heihei   ----id一定要与服务端用户id一样  可以用id xixi
#useradd xixi

(3)通过不同用户提权测试:

#su - xixi ----不能创建删除,只能读
$cifscreds add 172.24.8.128
redhat
$cd   /devops
$ll
$exit
#su - heihei
$cifscreds add 172.24.8.128
$cd /devops
$touch hei1
$touch hei2
$ll
[root@localhost devops]# ll
total 0
drwxr-xr-x. 2 root   root   6 Jul 17 02:32 1
drwxr-xr-x. 2 root   root   6 Jul 17 02:32 2
drwxr-xr-x. 2 root   root   6 Jul 17 02:32 3
drwxr-xr-x. 2 root   root   6 Jul 17 02:32 4
drwxr-xr-x. 2 root   root   6 Jul 17 02:32 5
-rwxr--r--. 1 heihei heihei 0 Jul 17 02:40 hei1
-rwxr--r--. 1 heihei heihei 0 Jul 17 02:46 hei2

二、第二题

配置dhcp实现动态分配和手动分分配方式
自动分配:

#yum install dhcp-server  -y
#vim /etc/dhcp/dhcpd.conf
# A slightly different configuration for an internal subnet.
subnet 192.168.159.0 netmask 255.255.255.0 {---声明网段和掩码
  range 192.168.159.200 192.168.159.250 ;---指定地址池范围
  option domain-name-servers 114.114.114.114 ;---指定DNS
  option routers 192.168.159.2 ;---指定网关
  option subnet-mask 255.255.255.0 ;--指定掩码
  default-lease-time 600;--默认租约
  max-lease-time 7200;--最大租约
}
#systemctl start httpd ----重启服务

在虚拟机上执行的操作如图
在这里插入图片描述
测试
首先杀死dhclient进程
kill -9 进程号----再次写上dhclient即可查询进程号
再次dhclient 即可查看

[root@localhost ~]# dhclient
dhclient(2966) is already running - exiting. 

This version of ISC DHCP is based on the release available
on ftp.isc.org. Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report issues with this software via: 
https://bugzilla.redhat.com/

exiting.
[root@localhost ~]# kill -9 2966
[root@localhost ~]# dhclient
[root@localhost ~]# ip a

手动分配
同样在#vim /etc/dhcp/dhcpd.conf添加

host A{
        hardware ethernet 00:0c:29:9f:d3:02;
        fixed-address 192.168.159.130;
}
#systemctl start httpd ----重启服务
[root@localhost ~]# dhclient
dhclient(2966) is already running - exiting. 

This version of ISC DHCP is based on the release available
on ftp.isc.org. Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report issues with this software via: 
https://bugzilla.redhat.com/

exiting.
[root@localhost ~]# kill -9 2966
[root@localhost ~]# dhclient
[root@localhost ~]# ip a ----即可查看手动配置的IP地址

提醒

记得还原虚拟网络设配器上的设置哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值