VM中桥接、仅主机、NAT模式下的网络连接和https网站搭建

任务1:画出vmware workstation的三种网络连接模式图,并给三个不同模式的网卡配置相应的ip参数并远程连接,测试哪种网络模式可以上网。
任务2:搭建一个基于https://www.zuoye.com:22222访问的web网站,网站首页在/www/https/,内容为zuoye

任务1:三种网络连接模式

NAT模式:

NAT模式下的网络连接模式图
在这里插入图片描述
通过此命令来查看当前网卡的配置信息

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 

在这里插入图片描述
远程连接上虚拟机并能访问外网上网通信
在这里插入图片描述

仅主机模式

仅主机模式的网络连接图
在这里插入图片描述
仅主机模式下也是通过DHCP自动获取地址
但不能访问外网
在这里插入图片描述

桥接模式

桥接模式下的网络连接图
在这里插入图片描述
进入该配置进行配置IP参数信息

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 

在这里插入图片描述

在这里插入图片描述

任务2:https网站搭建

搭建一个基于https://www.zuoye.com:22222访问的web网站,网站首页在/www/https/,内容为zuoye

步骤:

1.安装密码保护软件包

[root@localhost ~]# yum install mod_ssl -y

2.进入证书目录,创建密匙密码,

[root@localhost ~]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl genrsa -aes128 2048 > openlab.key
Generating RSA private key, 2048 bit long modulus (2 primes)
.+++++
............................................................................................................................................................+++++
e is 65537 (0x010001)
Enter pass phrase:
Verifying - Enter pass phrase:

3.创建安全证书

[root@localhost certs]# openssl req -utf8 -new -key openlab.key -x509 -days 365 -out openlab.crt
Enter pass phrase for openlab.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:xa
State or Province Name (full name) []:xa
Locality Name (eg, city) [Default City]:xa
Organization Name (eg, company) [Default Company Ltd]:xa
Organizational Unit Name (eg, section) []:xa
Common Name (eg, your name or your server's hostname) []:xian
Email Address []:admin@haha.com 
[root@localhost certs]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost certs]# systemctl restart httpd
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.

4.进入http子配置文件配置网页信息

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf 
Listen 22222
<VirtualHost 192.168.223.128:22222>
        ServerName 192.168.223.128
        DocumentRoot /www/https
        SSLEngine 'on'
        SSLCertificateFile /etc/pki/tls/certs/openlab.crt
        SSLCertificateKeyFile /etc/pki/tls/certs/openlab.key
</VirtualHost>
<Directory /www/https>
        AllowOverride none
        Require all granted
</Directory>
~                           

5.进入主机的hosts文件中添加IP和域名(hosts文件位于 C:\Windows\System32\drivers\etc)
在这里插入图片描述

6.访问该网站信息显示
在这里插入图片描述

任务完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值