Showing posts with label rhel 7. Show all posts
Showing posts with label rhel 7. Show all posts

Tuesday, 13 January 2015

Forgot root password of your RHEL 7 server. How to recover it ?

Let us discuss about a small topic. On RHEL 6.0 and earlier, an administrator could boot the system into runlevel 1, and be presented with  a root prompt. The closest analog to runlevel 1  on RHEL 7.0 machine are the rescue.target and emergency.target both of which require a root password to log in.

On RHEL 7.0, it is possible to have the scripts that run from the initramfs pause at certain points, provide root shell,and then continue to when the shell exits. this is mostly meant for debugging however it can also be used to recover the root password.

Here is the steps to recover the password :

1. Reboot the server.
2. Interrupt the boot loader countdown by pressing any key.
bootloader countdown
3. Press "e" to edit the selected entry.
4. move the cursor to the kernel command line (the line starts with linux16.)
5. Append rd.break (this will break just before control is handed from initramfs to the actual system)
rd.break
If you are recovering the root password of Virtual machine ( KVM) then you need to add serial console "console=ttyS0" along with "rd.break" otherwise we will not get the # prompt to change the password.
vm root password
6. Press CNTL+x to boot with changes.
At this point, a root shell will be presented, with the root filesystem for the actual system will be mounted read-only  on "/sysroot" .
recover shellFrom this shell we need to recover the password.
7. Remount the /sysroot as read-write mode.
# mount -o remount,rw /sysrootsysroot rw mode
8. Switch to chroot, where /sysroot is treated as the root of the filesystem tree.
# chroot /sysroot
chroot
9. Set a new password . Here i resetted my server password as redhat.
# echo "redhat" | passwd --stdin root
root password reset
10. Make sure that all the unlabeled files ( including /etc/shadow at this point) get labeled during boot.
#touch /.autorelabel
selinux updating

11.  exit twice. First will exit from chroot and second will from  the initramfs .
12. At this point, Server will reboot and now you could login with the new password set to root.

Hope you find this post useful ! if you have any feedback/queries post in the below comment box.!

Tuesday, 6 January 2015

DHCP Server configuration in RHEL 7.0


Dynamic Host Configuration Protocol (DHCP) As the name suggests, DHCP is used to control the network configuration of a host through a remote server. DHCP is an excellent alternative to the time-consuming manual configuration of network settings on a host or a network device.
It automatically assigns IP addresses and other network configuration information to systems on a network.

The following Diagram showing the DHCP Operation.



Let us check how to configure DHCP server in Redhat Enterprise Linux 7.0.
First we need to setup a static IP address for the DHCP Server. Use nmcli or edit the configuration file. click here to know how to configure ip address using nmcli.
 ip add
We need to install the DHCP Package using YUM or RPM. For more information on YUM configuration please chick here.
Run # yum install dhcp -y to install dhcp package .
yum dhcp installation
Let us check what all configuration files created after the dhcp package installation. run
# rpm -qlc dhcp command.
dhcp configuration files
Installing the dhcp package creates a file, /etc/dhcp/dhcpd.conf, which is merely an empty configuration file. This is configuration file for IPv4 DHCP .
dhcpd.conf
Looking into this file we could see that there is sample configuration file available for reference.
If do a cat on /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example you would get a better idea to configure DHCP server. there are lot of sample configurations available.
dhcp example conf file
The first step in configuring a DHCP server is to create the configuration file that stores the network information for the clients. Use this file to declare options for client systems.

Here is my DHCP server configuration. my IP address range is 192.168.1.101 to 192.168.1.111. and additionally we are give some options like netmask, router, domain, DNS etc.
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.101 192.168.1.111;
  option domain-name-servers 192.168.1.200;
  option domain-search "vinzlinux.com";
  option subnet-mask 255.255.255.0;
  option routers 192.168.1.100;
  default-lease-time 600;
  max-lease-time 7200;
}

dhcp config

Thats all about DHCP Configuration. There are many options available in DHCP configuration could you refer the man pages and example file for more information. lets restart the DHCP service and enable service.
# systemctl restart dhcpd
# systemctl status  dhcpd

# systemctl enable dhcpd

start dhcp

enable service
Now we need to work on client side. Check any ip address is configured in the client.  run #ip add show command.

There  no IP address is configured for eno16777736 interface now.
run #dhclient eno16777736 or take a reboot or restart NetworkManager this will get the ip address from the DHCP server.

dhclient
You could see the following entries in the /var/log/messages in the DHCP server.
/var/log/messages dhcp request
Fore IP lease information you could see in /var/lib/dhcpd/dhcpd.leases file in DHCP server.
You could see something similar to this.
dhcp leases

That's all about DHCP server configuration ..! Hope you found this article useful.