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虚拟机的三种网络配置

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 实例对比剖析c#引用参数的用法建议收藏

    c#引用参数传递的深入剖析值类型的变量存储数据,而引用类型的变量存储对实际数据的引用。(这一点很重要,明白了之后就能区分开值类型和引用类型的差别)在参数传递时,值类型是以值的形式传递的(传递的是值,对

    2021年12月21日
  • python Input输入

    python Input输入实例age:数字类型age:字符串类型age:输入数字类型转换字符串类型方式2%d数字%f浮点方式3

  • Centos7安装Postgresql 13 详细步骤(远程连接)

    Centos7安装Postgresql 13 详细步骤(远程连接)

  • Vc6.0打开该文件坠毁

    Vc6.0打开该文件坠毁

  • tomcat java_tomcat和maven的区别

    tomcat java_tomcat和maven的区别缓存什么是缓存[Cache]存在内存中的临时数据将用户经常查询的数据放在缓存(内存)中,用户去查询数据的时候就不用从磁盘上(关系型数据库数据文件)查询,从缓存中查询,从而提高查询效率,解决了高并发系统的性能问题。为什么使用缓存减少和数据库的数据交换次数,较少系统开销,提高系统效率什么样的数据库能使用缓存经常查询并且不经常改变的数据Mybatis缓存MyBatis 内置了一个强大的事务性查询缓存机制,它可以非常方便地配置和定制。默认情况下,只启用了本地的会话缓存,它仅

  • 应用date函数读取系统当前时间_获取系统时间的代码

    应用date函数读取系统当前时间_获取系统时间的代码在c#/ASP.net中我们可以通过使用DataTime这个类来获取当前的时间。通过调用类中的各种方法我们可以获取不同的时间:如:日期(2008-09-04)、时间(12:12:12)、日期+时间(2008-09-0412:11:10)等。//获取日期+时间 DateTime.Now.ToString();//2008-9-420:02:10 DateTime.Now.ToLo…

发表回复

您的电子邮箱地址不会被公开。

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