win10使用samba访问ubuntu目录
VMware安装ubuntu
VMware虚拟机中安装ubuntu后,使用 桥接模式,并勾选复制物理网络连接状态复选框
设置固定ip,修改文件/etc/network/interfaces
hj@ubuntu:/etc/network$ vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens33
iface ens33 inet static #这里设置静态地址static
address 192.168.3.18 #静态ip地址和电脑ip在同一个网段
gateway 192.168.3.1 #网关同电脑
netmask 255.255.255.0 #掩码同电脑
broadcast 192.168.3.255 #广播地址
dns-nameservers 192.168.3.1 #dns
需要配置dns否则不能上网,最好选择延时低的dns,如下dns对比
vim /etc/resolvconf/resolv.conf.d/base
#添加如下两行数据
nameserver 180.76.76.76
nameserver 223.5.5.5 223.6.6.6
nameserver 114.114.114.114 114.114.115.115
#使dns生效
sudo resolvconf -u
我的网络测试如下:不同网络提供商,网速不同
提供者 | 首选 | 备用 | 平均耗时(ms毫秒) |
---|---|---|---|
阿里 | 223.5.5.5 | 223.6.6.6 | 7 |
百度 | 180.76.76.76 | 6 | |
谷歌 | 8.8.8.8 | 8.8.4.4 | 245 |
114 | 114.114.114.114 | 114.114.115.115 | 17 |
重启网络
方法1:
service network restart
方法2:
/etc/init.d/networking restart
配置samba
省略安装samba步骤
vim /etc/samba/smb.conf
#在文件最后添加如下数据
[share] #共享名称
comment = My Samba #共享描述
path = /home/hj/share #共享的路径
browseable = yes #允许浏览
writeable = yes #允许写入
配置我的电脑的映射盘
右键我的电脑->映射网络驱动器,弹出窗口中选择一个盘符,输入网络文件夹路径\192.168.3.18\share即可