Prepare a standard host file

Hi,

I am trying to create custom analyses for Red Hat Enterprise server 6, to check Compliance of Hosts file Entry in Red Hat.

Need to verify Hosts entry for example 192.168.x.x ABC abc.xyz.com

If you’re looking to confirm an exact match, you can use:

exists lines whose (it contains "192.168.x.x ABC abc.xyz.com") of files "/etc/hosts"
2 Likes

Here’s an analysis that @jgstew wrote that’s a good starting point:

https://bigfix.me/analysis/details/2994561

3 Likes

Rather than looking for the specific entry, you would almost be better off extending the the analysis mentioned by cjwolford to return everything and then using a report to find the entry. Just thinking that you will probably be asked to look for other entries in the future :wink:

1 Like

Unless you want applicability relevance for a fixlet.


This is how you would get the valid lines of the hosts file on EVERY operating system:

(it as trimmed string) whose(it !="") of lines whose(it does not start with "#") of files "hosts" of folders ("/private/etc"; "/etc"; "\windows\sysnative\drivers\etc"; "\windows\system32\drivers\etc")

Then this is how you would check for a specific entry: (again, this works on ALL operating systems)

exists following texts whose(it as lowercase contains "abc.zyx.com") of firsts "192.168.1.1" of lines containing "192.168.1.1" whose(it does not start with "#") of files "hosts" of folders ("/private/etc"; "/etc"; "\windows\sysnative\drivers\etc"; "\windows\system32\drivers\etc")

You would just replace 192.168.1.1 and abc.zyx.com above as needed.

The @jgstew that wrote the analysis mentioned by @cjwolford was not as experienced as the @jgstew of today at writing cross platform relevance.

2 Likes

Can we create custom checklist for SCM

As far as I know, Yes, but I don’t have much context here. Do you mean for the hosts file? This is probably best asked separately.

yes for the hosts file