[Linux] I tried to verify the secure confirmation method of FQDN (CentOS7)

Introduction

I received such a question in a previous article.

スクリーンショット 2020-08-12 8.19.56.png

** [Previous article] ** [Linux] Why do I, an infrastructure engineer, not use the "hostname" command?

I'm sorry, but I didn't consider the FQDN. (Because there was no situation to check the FQDN in business.)

It's a big deal, so I'll try to verify it.

Information such as OS to be verified this time

OS version


[root@tspdev01 ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@tspdev01 ~]#

hostname


[root@tspdev01 ~]# cat /etc/hostname
tspdev01.example.com
[root@tspdev01 ~]#

** "You wouldn't do it as a root user in the first place!" ** I can understand such a voice well. (Basically, you do not log in to the existing server as root.)

However, this time I would like to do it as a root user for verification.

In the first place, what is the output result of "hostname -f"?

Execution command


hostname -f

Execution result


[root@tspdev01 ~]# hostname -f
tspdev01.example.com
[root@tspdev01 ~]#

When you check the execution result, it is displayed with FQDN(tspdev01.example.com).

Try with other commands

I would like to check the FQDN with another command.

Execute with the command that matches the question

Try running the command that matches your question.

Execution command


echo `uname -n`.`dnsdomainname`

The execution result looks like this.

Execution result


[root@tspdev01 ~]# echo `uname -n`.`dnsdomainname`
tspdev01.example.com.example.com
[root@tspdev01 ~]#

As a result, the domain is displayed twice.

Try running with "uname -n"

Execute with this command

Execution command


uname -n

The execution result is here.

Execution result


[root@tspdev01 ~]# uname -n
tspdev01.example.com
[root@tspdev01 ~]#

It was displayed by FQDN!

Try to display the host name as a short name

Short name display of normal host name

Execution command


hostname -s

The execution result is here.

Execution result


[root@tspdev01 ~]# hostname -s
tspdev01
[root@tspdev01 ~]#

Only the abbreviated system of the host name is displayed.

Short host name confirmation method using awk

Execution command


uname -n | awk -F "." '{print $1}'

The execution result is here.

Execution result


[root@tspdev01 ~]# uname -n | awk -F "." '{print $1}'
tspdev01
[root@tspdev01 ~]#

In this way, only the shortened host name can be displayed.

** Reference article ** How to specify the delimiter with awk's -F option

Check only domain name

Normal domain name confirmation method

Execution command


hostname -d

The execution result is here.

Execution result


[root@tspdev01 ~]# hostname -d
example.com
[root@tspdev01 ~]#

How to verify a secure domain name

Execution command


echo `dnsdomainname`

The execution result is here.

Execution result


[root@tspdev01 ~]# echo `dnsdomainname`
example.com
[root@tspdev01 ~]#

Only the domain name is displayed.

Summary

** Display method by FQDN **

uname -n

** Show only abbreviated host name **

uname -n | awk -F "." '{print $1}'

** Show domain name only **

echo `dnsdomainname`

Perhaps there are other ways. I haven't studied enough yet, so I will continue to catch up.

Recommended Posts

[Linux] I tried to verify the secure confirmation method of FQDN (CentOS7)
[Linux] I tried to summarize the command of resource confirmation system
I tried to summarize the frequently used implementation method of pytest-mock
I tried to touch the API of ebay
I tried to correct the keystone of the image
I tried to verify the result of A / B test by chi-square test
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to summarize the basic form of GPLVM
I tried to erase the negative part of Meros
I tried to simulate the dollar cost averaging method
I tried the simplest method of multi-label document classification
I tried to classify the voices of voice actors
I tried to summarize the string operations of Python
I tried to reintroduce Linux
[Linux] I learned LPIC lv1 in 10 days and tried to understand the mechanism of Linux.
I tried to find the entropy of the image with python
[Horse Racing] I tried to quantify the strength of racehorses
I tried to get the location information of Odakyu Bus
[Python] I tried to visualize the follow relationship of Twitter
[Machine learning] I tried to summarize the theory of Adaboost
I tried to fight the Local Minimum of Goldstein-Price Function
Commands and files to check the version of CentOS Linux
I tried to rewrite the WEB server of the normal Linux programming 1st edition with C ++ 14
I tried to verify the yin and yang classification of Hololive members by machine learning
I tried to move the ball
I tried to estimate the interval.
I want to get the name of the function / method being executed
I tried to create an environment of MkDocs on Amazon Linux
I tried to get the index of the list using the enumerate function
I tried to automate the watering of the planter with Raspberry Pi
I tried to build the SD boot image of LicheePi Nano
I tried to improve the efficiency of daily work with Python
I tried to visualize the common condition of VTuber channel viewers
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 1
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 2
I tried the asynchronous server of Django 3.0
I tried to summarize the umask command
Count / verify the number of method calls.
I tried to recognize the wake word
I tried to summarize the graphical modeling.
I tried to estimate the pi stochastically
I tried to touch the COTOHA API
I tried to transform the face image using sparse_image_warp of TensorFlow Addons
I tried to verify the best way to find a good marriage partner
I tried to get the batting results of Hachinai using image processing
I tried transcribing the news of the example business integration to Amazon Transcribe
I tried to estimate the similarity of the question intent using gensim's Doc2Vec
I tried how to improve the accuracy of my own Neural Network
I tried to solve the 2020 version of 100 language processing [Chapter 3: Regular expressions 25-29]
I tried to automatically extract the movements of PES players with software
I tried to summarize the logical way of thinking about object orientation.
I tried to find the optimal path of the dreamland by (quantum) annealing
I tried to extract and illustrate the stage of the story using COTOHA
I tried to analyze the negativeness of Nono Morikubo. [Compare with Posipa]
I tried to streamline the standard role of new employees with Python
I tried to summarize the Linux commands used by beginner engineers today-Part 1-
I tried to get the RSS of the top song of the iTunes store automatically
I tried to get the movie information of TMDb API with Python
I tried to display the altitude value of DTM in a graph
I tried the common story of using Deep Learning to predict the Nikkei 225