目录
2.3.更改虚拟机的网络配置,设置为NAT模式,关闭DHCP自动分配
一、环境准备:
1.需要将内存给到大于等于2G
2.更改虚拟机的网络配置,设置为NAT模式,关闭DHCP自动分配
3.设置静态IP
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
YPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" #关闭DHCP
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="256c0b54-40bf-4afe-94f7-e75423eb942a"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.20.16 #设置静态IP
PREFIX=24
GATEWAY=192.168.20.2 #设置网关
DNS1=119.29.29.29 #设置dns
关闭防火墙
[root@localhost ~]# systemctl stop firewalld #关闭防火墙
[root@localhost ~]# systemctl disable firewalld #禁止开机自启
[root@localhost ~]# systemctl status firewalld #查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled;
vendor preset: enabled)
Active: inactive (dead) #已经关闭
Docs: man:firewalld(1)
关闭SELINUX
安装yum源
root@localhost ~]# mount /dev/sr0 /mnt
[root@localhost ~]# mkdir /etc/yum.repos.d/bak
[root@localhost ~]# mkdir /etc/yum.repos.d/CentOS-*
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/bak
[root@localhost ~]# vim /etc/yum.repos.d/2001.repo
[01]
name=2001
baseurl=file:///mnt
enabled=1
gpgcheck=0
二、配置
安装软件
[root@localhost ~]# yum install -y httpd tftp tftp-server dhcp syslinux
配置DHCP
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
subnet 192.168.20.0 netmask 255.255.255.0 { #网段及网关
range 192.168.20.100 192.168.20.200; #地址池
option routers 1