Linux—Virtual machine simulation DHCP server experiment
Use the virtual machine as a DHCP server and configure a DHCP repeater in the eNSP to realize that the PC machine can automatically obtain an IP
step one
1. Configure eNSP, configure LSW1P with DHCP relay, and Cloud as the server host
2. The main configuration of LSW1:
dhcp enable
#Enable DHCP function interface Vlanif10
ip address 192.168.10.1 255.255.255.0
dhcp select relay #Enable DHCP relay function
dhcp relay server-ip 192.168.100.100 #Point to the address of the DHCP server
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.100.100
interface Vlanif100
ip address 192.168.100.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.100.100
3. The main settings of Cloud are as follows:
3. The other configuration is relatively simple, that is, some port type configuration, LWS2 plus vlan, and port type configuration
Step two
1. First, reconfigure the network card and IP
vim /etc/sysconfig/network-scripts/ifcfg-ens33
Remember to restart the network card after saving and exiting: systemctl restart network
Then it is best to check the network card: ifconfig
2. Configure the DHCP server
First, you need to install the dhcp software package, because the network type is only the host VMnet1. At this time, the installation needs to be mounted and the local yum source repository is configured
I have talked about these before, write the command:
mount /dev/cdrom /mnt/ #Mount the CD to the /mnt directory
cd /etc/yum.repos.d/
mkdir repos.bak
mv *.repo repos.bak Make a backup
cd /etc/yum.repos.d/
vim local.repo
[local] #Warehouse category
name=local
#Warehouse name baseurl=file:///mnt #Specify the URL access path is the CD mount directory
enabled=1 #Enable this yum source, this is the default item, can be omitted
gpgcheck=0 #do not verify the signature of the package
yum clean all && yum makecache #Delete yum cache and update
yum install -y dhcp
2. dhcp configuration
cd /etc/dhcp/
ls
less dhcpd.conf
cd /usr/share/doc/dhcp-4.2.5/
ls
less dhcpd.conf.example
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
It should be noted here that the /etc/dgcp/dhcpd.conf configuration file is empty, you need to copy this dhcpd.conf.example configuration file from /usr/share/doc/dhcp-4.2.5 into it, and then edit it with vim
vim dhcpd.conf.example
After saving and exiting, you need to turn on the dhcp function
systemctl start dhcpd
3. Choose the network of the virtual machine
4. Ping
ping 192.168.100.1
ping 192.168.10.1
ping 192.168.20.1
4. Back to eNSP, test that the pc can automatically obtain the ip address
[External link pictures are being transferred...(img-0whQ9ABe-1607241670182)]
4. Back to eNSP, test that the pc can automatically obtain the ip address