Configure network interface using nmtui

In my previous post, I wrote about how the network interface within a CentOS 7 environment can be configured to automatically get activated at boot up. In that post we discussed the command line tool

 ifup ens160 

and later edited the file

 /etc/sysconfig/network-scripts/ifcfg-ens160 

We can also achieve the same behaviour using the network manager text user interface also called as the nmtui.

  1. Start the nmtui wizard
     nmtui 
  2. select the Edit a Connection Option
    img1
  3.  Select the appropriate connection (network adapter) and then select edit
    img2
  4. On the edit screen use the select the Automatically connect checkbox and then select OK
    img3
  5. In case you want to temporarily deactivate (bring down) the network adapter (connection) use the Activate a connection option from the main screen.

The network manager TUI is an user interactive tool whereas there is also a non-interactive tool to achieve the same. The tool is called as:

 nmcli 
Advertisements

Automatic start up of network interface in CentOS 7

Today I installed CentOS 7 as a minimal install on my vSphere ESXi host. I had configured my virtual machine (VM) with a VMXNET3 network adapter. The good thing about this base minimal install of CentOS-7 is, that the network drivers are part of the base install. So essentially you don’t have to install VMware Tools to get the network adapter working. But the problem is the base minimal install of CentOS-7 by default only enables the loop-back adapter at boot. So the ens160 adapter does not (automatically) come up after boot.

This has nothing to do with the DHCP server not configured or the adapter requiring a static IP address. It’s a plain simple thing, that the ens160 adapter is disabled (probably for security reasons) on boot. To bring it up this network adapter you will need to login to the virtual machine and execute the following command:

ifup ens160

The interface will come up and get a DHCP IP address. However the interface will always need to be enabled manually after every reboot. If you want the interface to be automatically started after a reboot, then edit the following file:

vi /etc/sysconfig/network-scripts/ifcfg-ens160

and update the file to read as:

ONBOOT=yes

Keep all other settings as default, save the file and reboot. On the next boot the ens160 network adapter will automatically start with a DHCP IP address.

 

Configuring Text Boot on Ubuntu 12.04

I spent a lot of time trying to figure out how to disable plymouth and get a clean text boot on Ubuntu 12.04. Hence thought of documenting it in case I forget how I did it :-).

Edit /etc/default/grub and make the following changes:

  1. Modify the GRUB_CMDLINE_LINUX variable and set it as shown below.
    GRUB_CMDLINE_LINUX="init=/sbin/init -v noplymouth INIT_VERBOSE=yes"
    
  2. Uncomment the GRUB_TERMINAL variable. It should be set to as shown below:
    GRUB_TERMINAL=console
  3. Add a new line below the GRUB_TERMINAL variable declaration as shown below:
    GRUB_GFXPAYLOAD_LINUX=text
  4. Save the file /etc/default/grub
  5. Update the grub configuration and reboot.
    update-grub
    reboot
    

Thats it. You should get a clean text boot with Ubuntu now!!!

Script for adding Linux & Samba user concurrently

Today I needed a script to add a local Linux and samba user concurrently. I did a quick search and found nothing suitable, hence wrote one. Just in case someone needs it, they can copy it from here:

#!/bin/bash
SCRIPTNAME=`basename $0`
die() {
rc=$1
shift
printf "%s\n" "$*" >&2
exit $rc
}

showhelp() {
printf "${SCRIPTNAME} : \n\n"
printf "\tAdd a local linux user (with password) and add the user to samba db.\n"
printf "\tThe script will also add the user to an auxillary group \`tsusers'.\n"
printf "\tThe auxillary group  \`tsusers' has to be pre-existing on the system.\n\n"
printf "\tExample:\t${SCRIPTNAME} -u <username> -p <password>\n"
exit 2
}

if [ $# -lt 4 ] ; then showhelp ; fi

while getopts hp:u: opt
do
case $opt in
u) USERNAME=$OPTARG ;;
p) PASSWORD=$OPTARG ;;
h) showhelp; exit 2 ;;
*) showhelp; exit 2 ;;
esac
done

AUX_GROUP="tsusers"

if [ -z "${USERNAME}" ] ; then showhelp ; fi
if [ -z "${PASSWORD}" ] ; then showhelp ; fi

ENCRYPTED_PASSWORD=`perl -e 'print crypt("${PASSWORD}", "saltnpepper"),"\n"'`

adduser --quiet --disabled-login --gecos '' ${USERNAME} \
|| die 1 "${SCRIPTNAME}: failed to add user \`${USERNAME}'"

usermod --groups ${AUX_GROUP} ${USERNAME}
usermod --password "${PASSWORD}" ${USERNAME}
printf "${PASSWORD}\n${PASSWORD}\n" | smbpasswd -a -s ${USERNAME}

This is meant to be used on debian or Ubuntu, but I guess should work on most distributions with minor modifications.

Creating and managing local user accounts on vCenter Server Appliance

A couple of days back someone asked me how do we create a local user on the vCenter Server Appliance. So I started to understand how things work for local users on the vCenter Server Aplliance. Well it is pretty simple:

Steps:

  1. Enable SSH on your vCenter Server Appliance.
  2. Now login to your vCenter Server Appliance using a SSH client.
  3. Create a local user, here’s the command:
    useradd vcadmin

    Important: Donot use the useraddd.local command.

  4. Assign a password to the just created user.
    passwd vcadmin
  5. Using the vSphere client, login as root to your vCenter Server Appliance.
  6. Select the object on which you want to assign permissions for this user. Go to permissions tab for this object and add permissions for this user.
  7. That’s it.
  8. Test user login and you are done.
  9. If you need to create a root equivalent user, i.e. a vcenter administrator. You will assign the permissions on the vc-inventory-root (datacenters folder).

Note: vCenter Server Appliance, uses PAM libraries for authenticating users. The PAM libraries on vCenter Server Appliance have been configured for strong authentication. Thus if any user has more than 3 continuous failed logins, the user account would be locked.

You can check whether the user account is locked or not by running the following command on the vCenter Server Appliance over SSH login:

pam_tally  --user vcadmin

It will echo something like the following.

User vcadmin    (1005)  has 0

As long the user has 0 (zero), everthing is good, if it is more than 3, the account is locked. To unlock the account, run the following command:

pam_tally  --user <username> --reset

If its a AD account, unlock it using the following command:

pam_tally  --user username@domainname --reset

BTW, if you need to change the default number allowed failed logins from say 3 to 5, edit the following file and update approriately.

/etc/pam.d/common-auth

Although I have not tested this, I believe one should be able to add local groups in a similar way.

Call “HostDatastoreSystem.CreateVmfsDatastore” for object “ha-datastoresystem” on ESXi “host??.??????.com” failed.

Today I was playing in my home lab environment. After installing a new vSphere 4.1 host, I went on to add an  iSCSI target as a datastore, however it failed with an error

Call "HostDatastoreSystem.CreateVmfsDatastore" for object "ha-datastoresystem" on ESXi "host??.??????.com" failed.

I failed to understand why???

Just a day before I had used the same LUN to create a VMFS5 datastore on a vSphere 5.0 host. So I decided to investigate further. Logged in to the vSphere host via the troubleshooting shell and went through the /var/log/messages.

I found the following error:

Hostd:  Error : Unsupported partition table (gpt) on disk. Only msdos supported

Then I realized that when I created a VMFS5 partition on the same LUN, it also updated the disk label to “gpt”, and whereas vSphere 5.0 can understand both “gpt” & “msdos”, vSphere 4.1 is unable to handle the “gpt” labels .

The fix was to remove the gpt label! So I quickly assigned the said iSCSI LUN to my Linux box, and removed it using the parted utility.

root@linux-vm:~# parted /dev/sdd
GNU Parted 2.2
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
Warning: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) quit
Information: You may need to update /etc/fstab.

root@linux-vm:~#

After removing the “gpt” label, on retrying to create a VMFS3 filesystem on the said LUN, everything worked smoothly.

Moral of the Story: If you are planning to use/format a LUN with VMFS3 using vSphere 4.x and if you had used the LUN earlier to create a VMFS5 filesystem then you will first need remove the “gpt” label from your LUN.