When Backspace key does not work

Select and delete or retype. I have been doing that on my 2012 Acer Aspire One 725, including while typing this.

Advertisements

How to do a batch forward and reserve lookup using dig and host

For this example, I have a list of FQDNs and IPs in two files namely hostnames and ips. We will look at how to do a bulk query using dig and host in 6 examples.

1. Forward lookup using dig in batchmode and return only IPs

dig -f hostnames +short
192.168.1.148
192.168.1.149
192.168.1.150
192.168.1.151
192.168.1.152
192.168.1.153
192.168.1.154
192.168.1.181
192.168.1.182
192.168.1.183
192.168.1.184

2. Forward lookup using dig in batchmode and return A records

dig -f hostnames +noall +answer
rtfmp107.example.com. 479  IN      A       192.168.1.148
rtfmp109.example.com. 5    IN      A       192.168.1.149
rtfmp111.example.com. 900  IN      A       192.168.1.150
rtfmp113.example.com. 804  IN      A       192.168.1.151
rtfmp115.example.com. 804  IN      A       192.168.1.152
rtfmp117.example.com. 186  IN      A       192.168.1.153
rtfmp119.example.com. 5    IN      A       192.168.1.154
rtfmp139.example.com. 900  IN      A       192.168.1.181
rtfmp141.example.com. 4    IN      A       192.168.1.182
rtfmp143.example.com. 1    IN      A       192.168.1.183
rtfmp145.example.com. 1    IN      A       192.168.1.184

3. Bulk reverse lookup with dig and xargs

cat ips | xargs -Ih dig +noall +answer -x  h
148.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp107.example.com.
149.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp109.example.com.
150.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp111.example.com.
151.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp113.example.com.
152.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp115.example.com.
153.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp117.example.com.
154.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp119.example.com.
181.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp139.example.com.
182.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp141.example.com.
183.1.168.192.in-addr.arpa. 900 IN      PTR     rtfmp143.example.com.
184.1.168.192.in-addr.arpa. 352 IN      PTR     rtfmp145.example.com.

4. To extract just the names

cat ips  | xargs -Ih dig +noall +answer -x  h | awk '{print $5}' | sed 's/com./com/g'
rtfmp107.example.com
rtfmp109.example.com
rtfmp111.example.com
rtfmp113.example.com
rtfmp115.example.com
rtfmp117.example.com
rtfmp119.example.com
rtfmp139.example.com
rtfmp141.example.com
rtfmp143.example.com
rtfmp145.example.com

5. Forward lookup with host and xargs for a list of hostnames

cat hostnames | xargs -Ih host h
rtfmp107.example.com has address 192.168.1.148
rtfmp109.example.com has address 192.168.1.149
rtfmp111.example.com has address 192.168.1.150
rtfmp113.example.com has address 192.168.1.151
rtfmp115.example.com has address 192.168.1.152
rtfmp117.example.com has address 192.168.1.153
rtfmp119.example.com has address 192.168.1.154
rtfmp139.example.com has address 192.168.1.181
rtfmp141.example.com has address 192.168.1.182
rtfmp143.example.com has address 192.168.1.183
rtfmp145.example.com has address 192.168.1.184

6. Reserve lookup with host and xargs for a list of hostnames

cat ips | xargs -Ih host h
148.1.168.192.in-addr.arpa domain name pointer rtfmp107.example.com.
149.1.168.192.in-addr.arpa domain name pointer rtfmp109.example.com.
150.1.168.192.in-addr.arpa domain name pointer rtfmp111.example.com.
151.1.168.192.in-addr.arpa domain name pointer rtfmp113.example.com.
152.1.168.192.in-addr.arpa domain name pointer rtfmp115.example.com.
153.1.168.192.in-addr.arpa domain name pointer rtfmp117.example.com.
154.1.168.192.in-addr.arpa domain name pointer rtfmp119.example.com.
181.1.168.192.in-addr.arpa domain name pointer rtfmp139.example.com.
182.1.168.192.in-addr.arpa domain name pointer rtfmp141.example.com.
183.1.168.192.in-addr.arpa domain name pointer rtfmp143.example.com.
184.1.168.192.in-addr.arpa domain name pointer rtfmp145.example.com.

Find all ESXi hosts in a subnet

I have got a task to clear subnets off non-VMware hosts so we can turn on dhcp, PXE for Auto Deploy. I have identified inactive IPs and our DNS admin reclaimed them. I need a way to verify the active IPs are VMware ESXi.

My first method is to ssh to the IPs and run vmware -v in a for loop.

for i in `cat list`
do 
    ssh -q -o "BatchMode yes" root@$i vmware -v
done

We have ssh keys setup but for every subnet there are a bunch of hosts where I cannot ssh with keys. I do not have the time to fix them all.
Continue reading

Verify you can ssh to a list of hosts using keys

for i in `cat list` 
do 
    ssh -o "BatchMode yes" root@$i hostname
done

ssh to a list of hosts and run the hostname command to verify you can ssh to the hosts password-lessly. If password-less login is not working, it will not prompt for passphrase or password and will skip it.

man ssh_config

BatchMode
If set to “yes”, passphrase/password querying will be disabled. This option is useful in scripts and other batch jobs where no user is present to supply the password. The argument must be “yes” or “no”. The default is “no”.

Access a shell prompt and issue commands with correct syntax

While preparing for RHCE RHEL 6 (available upto March 31, 2016), I came across this website which does an easy to follow cheat sheet of sort for each topics under the RHCE/RHCSA Exam objectives. I was hugely impressed and wanted to do something similar. This is my attempt at creating a cheat sheet for RHCE/RHCSA RHEL 7.

Now to the topic. Anyone attempting RHCE should already know how to launch a terminal to access the shell and run commands. If you are really that fresh to Linux, among the many many resources available online I recommend Daniel Robin’s Linux Fundamental series and Introduction to Linux by the Linux Foundation at EdX.
Continue reading