桥接模式
查看主机的ip地址、网关、DNS等信息
进入系统编辑网卡配置文件
命令为vi /etc/sysconfig/network-scripts/ifcfg-eth0
虚拟机网卡配置文件内容:
设置虚拟机ip地址,与主机ip地址在同一网段
设置子网掩码
设置虚拟机网关,与主机相同
设置虚拟机DNS,与主机相同
编辑完成,保存退出,然后重启虚拟机网卡,使用ping命令ping外网ip,测试能否联网。
NAT
开机启动系统,编辑网卡配置文件,命令为vi /etc/sysconfig/network-scripts/ifcfg-eth0
编辑完成,保存退出,然后重启虚拟机网卡,使用ping命令ping外网ip,测试能否联网。
仅主机
开机启动系统,然后设置网卡文件。
保存退出,然后重启网卡,利用远程工具测试能否与主机通信。
重新配置网卡,将虚拟网卡作为虚拟机的路由。
重启网卡,然后通过 远程工具测试能否联通外网以及与主机通信。
搭建一个基于https:///www.zuoye.com:22222访问的web 网站,网站首页在/www/https/,内容为zuoye
搭建之前确保光盘已挂载,并且yum源已写好
安装httpd 、mod_ssl包
[root@localhost ~]# yum httpd -y
[root@localhost ~]# yum install mod_ssl -y
切换到/etc/httpd/conf.d目录下
[root@localhost certs]# cd /etc/httpd/conf.d
安装mod_ssl 包,安装lrzsz包
[root@localhost conf.d]# yum install mod_ssl -y
[root@localhost certs]# yum install lrzsz -y
新建IP 并激活
创建并编辑 vhost-https.conf 文件
[root@localhost conf.d]# vim vhost-https.conf
创建证书文件
先切换到 /etc/pki/tls/certs/ 目录
[root@localhost ~]# cd /etc/pki/tls/certs/
创建一个私钥文件 https.key
[root@localhost certs]# openssl genrsa -aes128 2048 > http.key
再创建一个于私钥匹配的公钥文件,制作成证书
[root@localhost certs]# openssl req -utf8 -new -key https.key -x509 -days 365 -out https.crt -set_serial 0
重新切换到/etc/httpd/conf.d目录下,编辑vhost-https.conf文件
[root@localhost certs]# cd -/etc/httpd/conf.d
[root@localhost conf.d]# vim vhost-https.conf
创建目录
[root@localhost conf.d]# mkdir /www/https
[root@localhost conf.d]# mkdir /usr/local/secret
创建认证文件
[root@localhost conf.d]# htpasswd -c /etc/httpd/renzheng xiaoming
New password:
Re-type new password:
Adding password for user xiaoming
[root@localhost conf.d]# cat /etc/httpd/renzheng xiaoming
写index文件
[root@localhost conf.d]# echo zuoye >//www/https/index.html
[root@localhost conf.d]# echo mimi >/usr/local/secret/index.html
重启
[root@locahost~]#systemctl restart httpd
访问
https://192.168.218.128:22222