VMWare虚拟机的三种网络配置

VMWare虚拟机的三种网络配置背景:当前物理机ip:192.168.18.8,路由器IP:192.168.18.1(相当于网关)我学习linux系统时,在主机上配置了二种网络类型,其中NAT模式不需要关闭防火墙即可与主机相互pin

大家好,又见面了,我是你们的朋友全栈君。

背景:当前物理机ip:192.168.18.8,路由器IP:192.168.18.1(相当于网关)我学习linux系统时,在主机上配置了二种网络类型,其中NAT模式不需要关闭防火墙即可与主机相互ping通,桥接模式需要两者互相关闭防火墙(linuxprobe为Nat,linuxprobeB为桥接)

<span role="heading" aria-level="2">VMWare虚拟机的三种网络配置  <span role="heading" aria-level="2">VMWare虚拟机的三种网络配置

说明 :VMare的网络连接有三种类型,其中最常用的NAT网络地址转换和桥接两种网络模式都可以既使用固定ip,又能和物理主机互相通讯,也能访问外网,这两种方式都需要先配置vmware的设置

<span role="heading" aria-level="2">VMWare虚拟机的三种网络配置  <span role="heading" aria-level="2">VMWare虚拟机的三种网络配置

 

VMware的网络连接有三种类型

1.虚拟机设置为桥接模式(使用VMnet0网卡):物理机与虚拟机从属一个网段,且为平级关系,虚拟机可以访问局域网内任何一台机器。与物理机通信的时候需要配置好IP和掩码(DHCP也可),如果你的局域网里有很多机器想要互相通信,那应该选择桥接,桥接模式的虚拟机IP必须与主机在同一网段,且子网掩码网关和DNS也一致

<span role="heading" aria-level="2">VMWare虚拟机的三种网络配置

笔记本无线网卡连接外网,物理网卡与台式机连接成局域网(192.168.18.9),由笔记本通过ftp登陆linuxprobeB(192.168.18.10)需要一下几个步骤:

手动配置linuxprobeB ip子网、网关、DNS

<span role="heading" aria-level="2">VMWare虚拟机的三种网络配置

 

 

 01安装ftp(已配置好软件源),#yum install -y ftp

02编辑/etc/vsftpd/vsftpd.conf,确定你要设置的登陆认证模式,包括匿名开放登陆、本地用户模式、虚拟用户模式

匿名登陆模式:匿名模式的默认登陆路径:/var/ftp,使用ls -ld 查看该目录的所有者权限,结果是root,则chown -R ftp /var/ftp/pub,于是乎具有写入权限

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
anon_upload_enable=YES//允许匿名用户上传文件
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES//允许匿名用户对目录具有写权限
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES

本地用户模式,这种模式默认访问的是用户的家目录,而该目录的所有者都是该用户,所以登陆过去不存在权限问题,如果禁止该用户的部分权限再用chmod设置即可

 useradd INSP

passwd INSP(一定不要建不支持登陆的用户,例如-s /sbin/nologin INSP,这种ftp是登陆不上的)

# Example config file /etc/vsftpd/vsftpd.conf

#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

pam_service_name=vsftpd
userlist_deny=YES userlist_enable=YES

 

03再设置开机启动和vsftpd服务重启(两者都是必要的)

再用笔记本直接ftp访问,都是可以直接访问到的,一定主意ftpusers 和 user_list两个文件的功能,

ftpuser文件# Users that are not allowed to login via ftp里面定义的用户名都是不可用与ftp登陆的,

userlist文件定义的根据vsftpd.conf中 userlist_deny=定义的不同,No表示白名单,YES表示黑名单,并且在用户名在该文件检查文白名单后也要继续检查ftpuser文件,所以一定不要配错了
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.

 

单独来说虚拟用户登陆设置

 

 2.虚拟机设置为NAT模式(网络地址转换模式)。VMWare虚拟机默认的NAT模式下虚拟系统的TCP/IP配置信息是由VMnet8(NAT)虚拟网络的DHCP服务器提供的,不支持手动设置ip。假如想要虚拟机内有固定的的ip,则需要配置虚拟机软件+配置主机虚拟网卡IP+修改网络配置文件(具体操作如下),。物理机与虚拟机从属两个网段,因此虚拟系统也就无法和本局域网中的其他真实主机进行通讯。如果你只是在家自己用虚拟机,没有局域网概念,那选择NAT模式无需配置IP掩码等即可直接上网

<span role="heading" aria-level="2">VMWare虚拟机的三种网络配置 <span role="heading" aria-level="2">VMWare虚拟机的三种网络配置<span role="heading" aria-level="2">VMWare虚拟机的三种网络配置  <span role="heading" aria-level="2">VMWare虚拟机的三种网络配置  <span role="heading" aria-level="2">VMWare虚拟机的三种网络配置

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154513.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 可能错误使用了‘offsetof’宏

    可能错误使用了‘offsetof’宏最近代码里引进了一个宏offsetof(s,m),原来一直在windows上开发,今天发现在linux编译的日志中出现了如下的警告:xxxx.cpp:8:警告:对NULL对象非静态数据成员‘XXX::xxx’的访问无效xxxx.cpp:8:警告:(可能错误使用了‘offsetof’宏)

    2022年8月22日
    3
  • 2020微信小程序反编译教程(小程序反编译源码能用吗)

    文章主要实现:废话不多说下面就直接来流程了!第1步:先安装node.js点击下载第2步:再下载wxappUnpacker反编译包点击下载包第3步:保证以上都安装后电脑命令窗口:CMD运行第2步目录运行加载node依赖:命令窗口复制以下黄色命令:npminstalluglify-es–savenpminstall…

    2022年4月16日
    366
  • 10.10.10.1可以设置为网关吗_个人如何做跨境电商

    10.10.10.1可以设置为网关吗_个人如何做跨境电商【大型电商项目开发】商品服务-配置网关路由与路径重写-10

    2022年7月28日
    3
  • vue x 兼容iphone_作为前端你必须知道的iPhoneX适配

    ​1.iPhoneX的介绍屏幕尺寸我们熟知的iPhone系列开发尺寸概要如下:△iPhone各机型的开发尺寸转化成我们熟知的像素尺寸:△每个机型的多维度尺寸倍图其实就是像素尺寸和开发尺寸的倍率关系,但这只是外在的表现。倍图核心的影响因素在于PPI(DPI),了解屏幕密度与各尺寸的关系有助于我们深度理解倍率的概念:《基础知识学起来!为设计师量身打造的DPI指南》iPhone8在本次升级中,屏…

    2022年4月13日
    46
  • 小草 客户端 android,小草app安卓版入口

    小草 客户端 android,小草app安卓版入口这里小编为大家提供一个非常不错的线上的看剧软件哦,这里每天都会更新一些市面上比较火爆的各种视频资源,而且更新的速度也是十分的快捷的,无需任何的花费,的大家就可以轻松的在线来观看了。整个平台为大家提供的各种服务也是十分的优质的,线上还有专业的客服人员在线为大家提供更加优质的服务哦。小草app安卓版入口的特色:1、线上的所有的视频资源内容都是有平台专业的人士为大家进行审核的,保证都是正版的内容哦;2、…

    2022年6月15日
    222
  • Chrome内核浏览_三大浏览器内核

    Chrome内核浏览_三大浏览器内核C#开发Chrome内核浏览器(WebKit.net)WebKit.net是对WebKit的.Net封装,使用它.net程序可以非常方便的集成和使用webkit作为加载网页的容器。这里介绍一下怎么用它来显示一个网页这样的一个最简单的功能。第一步:下载WebKit.net的bin文件。别小看这一步,你不一定能下载成功,原因你懂的。WebKit.net的主页是http://webkitdotnet.sourceforge.net/直接下载0.5版本的windowsbin文件地址为:h

    2022年10月28日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号