项目十 网络服务器搭建及应用


I know, i know
地球另一端有你陪我




IP

1、IP 地址

windows系统输入 cmd ,进入命令提示符,命令行输入 ipconfig 查询虚拟机网段

找到 以太网适配器 VMware Network Adapter VMnet8
这个 IPv4 就是你的网段,比如我这里就是192.168.133

在这里插入图片描述

在 linux 中打开网卡配置文件

sudo vim /etc/sysconfig/network-scripts/ifcfg-ens160

按 i 进入插入模式(左下角会有提示)

BOOTPROTO=static              # 静态网络
ONBOOT=yes                    # 启动网卡
IPADDR=192.168.40.100         # IP地址
NETMASK=255.255.255.0         # 子网掩码
GATEWAY=192.168.40.2          # 网关地址
DNS1=114.114.114.114		  # DNS服务器1
DNS2=8.8.8.8     	          # DNS服务器2

之后按 esc ,再按 : (冒号),进入底线命令模式(左下会出现冒号提示)
输入 wq,保存并退出

然后重启网络:
redhat8

ifdown ens160;ifup ens160       

centos7

service network restart    

centos7

systemctl restart network       

2、配置 yum 源为阿里源

http://mirrors.aliyun.com/repo/Centos-8.repo

全选复制以下文档内容
# 代表注释,可以忽略

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.


 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

打开当前系统的yum源配置文件,并粘贴在下面

sudo vim /etc/yum.repos.d/redhat.repo

重新生成缓存文件

sudo yum clean all
sudo yum makecache


redhat 8 安装 Samba

通过搭建Samba服务器,实现局域网内的共享文件夹的作用

1、安装Samba相关服务

sudo yum install samba samba-client samba-common
samba-common软件包:提供了samba服务器和客户机都必须使用的公共文件。

samba-client软件包:提供了samba客户机所有的文件。

samba软件包:提供了samba服务器所有的文件。

2、启动并使 Samba 服务开机自启

sudo systemctl enable --now smb nmb

3、samba服务在火墙添加启用

sudo firewall-cmd --permanent --add-service=samba
sudo firewall-cmd --reload

或者直接禁用防火墙

systemctl stop firewalld

4、设置Samba密码

sudo useradd haamsing(或者useradd username -s /sbin/nologin 创建不登录帐户?)
sudo smbpasswd -a haamsing

haamsing 是用户名,可以自定义的

5、创建共享目录并设置权限:

755只能看,777可以写入

sudo mkdir -p /share/samba
sudo chmod -R 0755 /share/samba

6、配置Samba共享,编辑 /etc/samba/smb.conf 文件,添加共享信息:

sudo vim /etc/samba/smb.conf

添加以下内容到文件末尾:

[share]

    path = /share/samba
    #共享地址

    writable = yes 
    #可以写入

    guest ok = yes
    #允许guest访问

    guest only = yes

    create mode = 0755 
    #创建文件权限755

	directory mode = 0755 
	#创建目录权限755

这里会产生个人用户的Home共享,需要删除【home】下的全部内容

7、重启Samba服务以应用配置更改:

sudo systemctl restart smb nmb

8、一定要关闭selinux(否则会造成windows客户机连接Samba失败)

vim /etc/sysconfig/selinux

SELINUX=disabled   #修改此处

再输入以下命令,关闭强制访问控制

setenforce 0

搜索栏输入

\\你的IP
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值