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)
blank

相关推荐

  • mssql datetime smalldatetime 字段类型插入代码「建议收藏」

    mssql datetime smalldatetime 字段类型插入代码「建议收藏」
    如果mssql字段类型是datetime ,插入代码如下
                   ps=conn.prepareStatement(strSQL2);
                   ps.setString(1,(newjava.util.Date()).toLocaleString());  
                   ps.executeUpdate();
     
    如果mssql字段类型

  • 在WIN7系统的笔记本上建立WIFI热点「建议收藏」

    在WIN7系统的笔记本上建立WIFI热点

  • windows下如何安装git及配置环境_git安装失败

    windows下如何安装git及配置环境_git安装失败下载安装1.从git官网下载一个git安装包,官网下载地址http://www.git-scm.com/download/2.双击安装程序(如果没有SecurityWarning请跳过此步骤),请点击【Run&gt;】3.阅读协议,点击【Next&gt;】4.选择安装位置,点击【Next&gt;】5.选择安装组件:这里可以使用默认选项,点击【Next…

  • 《算法图解》-9动态规划 背包问题,行程最优化

    《算法图解》-9动态规划 背包问题,行程最优化本文属于《算法图解》系列。学习动态规划,这是一种解决棘手问题的方法,它将问题分成小问题,并先着手解决这些小问题。一背包问题背包问题,在可装物品有限的前提下,尽量装价值最大的物品,如果物品数量足够大,简单的暴力穷举法是不可行的O(2ⁿ),前一章介绍了《贪婪算法》就是解决如何找到近似解,这接近最优解,但可能不是最优解。如何找到最优解呢?就是动态规划算法。动态规划先解决子问题,…

  • C#面试题及答案_c++面试题库

    C#面试题及答案_c++面试题库1.值变量/引用变量参考链接:https://www.cnblogs.com/bakuhert/articles/5878086.html2. 装箱/拆箱    装箱在值类型向引用类型转换时发生,拆箱在引用类型向值类型转换时发生,装箱操作和拆箱操作是要额外耗费cpu和内存资源的,所以在c#2.0之后引入了泛型来减少装箱操作和拆箱操作消耗。   参考链接:https://blo…

  • Windows Server 2016 检查更新时,错误代码8024401C 的解决方案 …

    Windows Server 2016 检查更新时,错误代码8024401C 的解决方案 …这个问题的核心是连接不到更新服务器,有多种解决方案(如给SoftwareDistribution改名、疑难解答等),还有一部分情况是因为IPV6导致,关闭IPV6即可解决。如果其他办法都不好用可以试试这个~WindowsServer关闭ipv6的办法:开始->运行->输入Regedit进入注册表编辑器定位到:[HKEY_…

发表回复

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

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