本文共 5091 字,大约阅读时间需要 16 分钟。
虚拟网络编辑器:
本机网卡两个dns分别为:
202.96.128.86
202.96.134.133新建虚拟机:
如下虚拟机位置建议不要放在C盘
虚拟机配置:
启动模板机,安装centos 7.2
用root账号密码123456登录
关闭防火墙systemctl disable firewalld关闭防火墙开机启动systemctl stop firewalld关闭selinuxsed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
ip a最后一个网卡为vmnet8网卡
[root@localhost ~]# ip a1: lo:mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:19:ce:56 brd ff:ff:ff:ff:ff:ff3: eno33554960: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:19:ce:60 brd ff:ff:ff:ff:ff:ff4: eno50332184: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:19:ce:6a brd ff:ff:ff:ff:ff:ff inet 10.0.0.100/24 brd 10.0.0.255 scope global eno50332184 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe19:ce6a/64 scope link valid_lft forever preferred_lft forever
vmnet8网卡配置为如下:(DNS是通过宿主网卡属性信息或者ipconfig /all查到的)
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno50332184TYPE=EthernetBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=noNAME=eno50332184UUID=51b49bab-01b5-4464-b86d-5975c8cee453DEVICE=eno50332184ONBOOT=yesIPADDR=10.0.0.100NETMASK=255.255.255.0GATEWAY=10.0.0.2DNS1=202.96.128.86DNS2=202.96.134.133
网卡vmnet1和vmnet2不要配置网关和DNS
修改完后重启网卡:
[root@localhost ~]# systemctl restart network
重启后直接用SecureCRT登录模板机后,再进行如下操作:
vmnet1网卡配置如下:
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736TYPE=EthernetBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=noNAME=eno16777736UUID=316f6b4d-a4e4-48ba-8b66-e178c98ead5fDEVICE=eno16777736ONBOOT=yesIPADDR=10.1.1.120NETMASK=255.255.255.0
vmnet2网卡配置如下:
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno33554960TYPE=EthernetBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=noNAME=eno33554960UUID=1ec0daa5-ebde-42d6-b26f-9484ac1f39ebDEVICE=eno33554960ONBOOT=yesIPADDR=10.2.2.120NETMASK=255.255.255.0
重启网卡
[root@localhost ~]# systemctl restart network[root@localhost ~]# ip a1: lo:mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:19:ce:56 brd ff:ff:ff:ff:ff:ff inet 10.1.1.120/24 brd 10.1.1.255 scope global eno16777736 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe19:ce56/64 scope link valid_lft forever preferred_lft forever3: eno33554960: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:19:ce:60 brd ff:ff:ff:ff:ff:ff inet 10.2.2.120/24 brd 10.2.2.255 scope global eno33554960 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe19:ce60/64 scope link valid_lft forever preferred_lft forever4: eno50332184: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:19:ce:6a brd ff:ff:ff:ff:ff:ff inet 10.0.0.100/24 brd 10.0.0.255 scope global eno50332184 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe19:ce6a/64 scope link valid_lft forever preferred_lft forever
看是否可以访问外网:ping 网关和外网baidu网址
[root@localhost ~]# ping -c4 10.0.0.2PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.64 bytes from 10.0.0.2: icmp_seq=1 ttl=128 time=1.69 ms64 bytes from 10.0.0.2: icmp_seq=2 ttl=128 time=0.645 ms64 bytes from 10.0.0.2: icmp_seq=3 ttl=128 time=0.552 ms64 bytes from 10.0.0.2: icmp_seq=4 ttl=128 time=1.09 ms--- 10.0.0.2 ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3040msrtt min/avg/max/mdev = 0.552/0.996/1.695/0.452 ms[root@localhost ~]# ping -c4 baidu.comPING baidu.com (123.125.114.144) 56(84) bytes of data.64 bytes from 123.125.114.144: icmp_seq=1 ttl=128 time=123 ms64 bytes from 123.125.114.144: icmp_seq=2 ttl=128 time=37.9 ms64 bytes from 123.125.114.144: icmp_seq=3 ttl=128 time=37.3 ms64 bytes from 123.125.114.144: icmp_seq=4 ttl=128 time=38.7 ms--- baidu.com ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3030msrtt min/avg/max/mdev = 37.357/59.400/123.520/37.023 ms
安装常用的基础包:
[root@localhost ~]# yum install vim net-tools wget tree telnet dos2unix sysstat lrzsz nc nmap -y
修改主机名:
例如把默认主机名localhost.localdomain修改为oldboy,修改完后直接重启系统。
[root@localhost ~]# vi /etc/hostname
重启后直接关机做个快照,快照名:模板机,
一定不要执行yum update -y && reboot 否则会升级到更高的版本。
openstack ocata版本对centos 7.2以上的版本兼容性比较差,只建议用centos 7.2版本。
这里没有设置centos base源和epel源,如要设置,可以设置阿里云的yum源。