DHCP Setup Notes - Oliver-Mustoe/Oliver-Mustoe-Tech-Journal GitHub Wiki
In this page I detail how I configured a DHCP service on a CentOS VM
Notes
First on WKS01, I downloaded PUTTY from https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe, or can use https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html, and then started PUTTY.
Then I ssh'd into dhcp01-firstname by entering "dhcp01-firstname" into the field below "Host Name (or IP address)" and clicking open.
Here it asked me who to login as, which I used my firstname as it is the user I set in the setup notes of SYS255-Entry for: Introduction to Linux, and the password I setup for that user in the same notes section.
Then after I ran the command to install the dhcp service with the command:
"sudo yum install dhcp"
Command breakdown:
- sudo - makes so the command is run as an admin, will require password to execute
- yum - this is the package manager, we are invoking it to do something
- install - telling yum we want to install something
- dhcp - telling yum what we want to install
For any prompts it asks I enter "y" to answer yes.
Then I became root with the command "sudo -i", which required a password. Then I entered in the command:
"nano /etc/dhcp/dhcpd.conf"
Command breakdown:
- nano - using the nano text editor, telling it I want to edit something
- /etc/dhcp/dhcpd.conf - the something I want to edit
In the text editor I manueverd down below the lines starting with #, these lines are comments, and entered in the following text:
MUST BE ENTERED EXACTLY AS FOLLOWS, THE LINES STARTING WITH "---" ARE INDENTED
subnet 10.0.5.0 netmask 255.255.255.0 {
---option routers 10.0.5.2;
---option subnet-mask 255.255.255.0;
---option domain-name "firstname.local";
---option domain-name-servers 10.0.5.5;
---range 10.0.5.100 10.0.5.150;
}
Then I pressed ctrl+x to save, it will ask for a name just press enter.
Then I started the service with the command:
"systemctl start dhcpd"
IF THIS DOESNT WORK USE "journalctl -xe" TO READ THE ERROR MESSAGE
Command breakdown:
- systemctl - provides systemd control
- start - telling systemd to start a service
- dhcpd - what service we are telling systemd to start
I then ran the command "systemctl status dhcpd", only change from above is we are asking for the status of the dhcpd service not to start it, to see if everything was running correctly. After the command was run I saw that it was active in the "Active" section of the service status.
I then ran the command "systemctl enable dhcpd" so that the dhcpd service would start on boot.
Next on dhcp01 I enabled the firewall, but first I used the firewall-cmd utility to check on what could currently go through the firewall with the command:
"firewall-cmd --list-all"
That gave a list, the particular section we want to focus on is "services" which should look like this currently:
"services: dhcpv6-client ssh"
Then I used these two commands in sequence:
- firewall-cmd --add-service=dhcp --permanent
- firewall-cmd --reload
THERE SHOULD BE A "success" POPUP THAT COMES AFTER EACH COMMAND
I then re-entered command from above:
"firewall-cmd --list-all"
Where now the service section looks as follows:
"services: dhcp dhcpv6-client ssh"
I then entered "exit" numerous times until putty closed.
From here I went into my IP properties, explained here, and changed the settings to "Obtain an IP address automatically" and "Obtain DNS server address automatically".
I would then use the command "ipconfig /all" to see that WKS01 settings were all good and DHCP was enabled. I would also do a ping of google.com to make sure everything worked correctly.