- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- USING WINDCARDS IN THE /ETC/HOSTS FILE
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:29 AM
08-13-2004 03:29 AM
I made a /etc/hosts file with all necessary information about my hosts, such as owner, localization. Worked fine.
But when I tried to ping using wildcards * , it doesnt worked.
Anyone has the answer ?
Thks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:34 AM
08-13-2004 03:34 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
man hosts
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:34 AM
08-13-2004 03:34 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
I have tried to reproduce as,
-- /etc/hosts --
IP-Address FQDN alias
xx.xx.xx.xx test.test.com *test
--------
ping *test
It is getting resolved
nslookup *test
It is working.
How did you tried out?? which os version. I have tried on 11.23
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:36 AM
08-13-2004 03:36 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
Can you give us an example of what you tried and what exactly you are trying to do? I'm not sure I understand your question completely.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:37 AM
08-13-2004 03:37 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
Host names can contain any printable character other than a white
space, newline, or comment character.
It is again on 11.23
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:38 AM
08-13-2004 03:38 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
Can't use wildcards in either the hosts file or ping commands.
If you want to ping all hosts in a subnet you ping the broadcast address - which is usually xxx.xxx.xxx.255 unless the network is subnetted or supernetted.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:38 AM
08-13-2004 03:38 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
1.1.1.1 host1
1.1.1.2 host2
1.1.1.3 host3
etc
He's then trying to ping host* to get a ping response from each host, which is not possible.
The nearest that can be achieved to this (without scripting a solution) is to ping the broadcast address (if all your hosts are on the same subnet)
Try "ping 1.1.1.255" (change 1.1.1 to your own IP address prefix)
This should try to ping every host with a 1.1.1 prefix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 03:55 AM
08-13-2004 03:55 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 05:16 AM
08-13-2004 05:16 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
1.1.1.1
12.36.120.4
150.163.25.3
I am using naming to fix it.
For example:
host1.location1.owner1 and so on.
When I try *.location1.* or host1.*.* , the DNS isnt working.
Anyone knows how to do that ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 05:43 AM
08-13-2004 05:43 AM
SolutionI really don't think there is a way to do this on the ping command line. Your best bet may be to use a simple script, like:
for HOST in $(grep
do
ping $HOST -n 2
done
This will send 2 ICMP packets to each system that the grep string matches.
Hope this helps, or at least gives you some ideas of how to do what you're looking for.
Regards,
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 05:46 AM
08-13-2004 05:46 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
There is no way to do it that. DNS does not accept wildcards - neither on hostname nor domain.
What you'd have to do is parse the hosts file for either the hostname or domain & construct a for loop from the results.
Example of a hostname match:
for host in $(grep hostname /etc/hosts | awk '{print $2}')
do
ping -n 5 $host
done
This would ping matching hostnamenames using the FQDN 5 times.
This assumes that your hosts file uses only FQDN
111.222.111.222 hostname.company.com
111.222.112.222 hostname.company2.com
111.222.113.222 hostname.company3.com
111.222.111.223 hostname2.company.com
111.222.111.224 hostname3.company.com
111.222.112.223 hostname2.company2.com
111.222.113.223 hostname3.company3.com
Then to do domain pings then just change the grep search for company2.com or such.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 05:47 AM
08-13-2004 05:47 AM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
That would work fine.
Thanks...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2004 12:20 PM
08-14-2004 12:20 PM
Re: USING WINDCARDS IN THE /ETC/HOSTS FILE
ping *test
and
nslookup *test
you did not look in /etc/hosts for a series of matches. What happened was that the *test string was replaced with whatever was in your current working directory. ping and nslookup NEVER saw the * character. Instead, they saw a filename in your current working directory (probably "test"). Neither ping nor nslookup do anything wih * except to treat it as part of the hostname. To prove this, type these commands:
nslookup *test
echo nslookup *test
cd /usr
nslookup *test
echo nslookup *test
nslookup '*test'
The first (if you are sitting in a directory where a file or directory ending in "test" exists) nslookup sees just test. The echo shows what your shell does to the command line before passing it to nslookup.
Now cd to /usr where there (hopefully) are no test files and you'll see nslookup now fails: your.dns.server: can't find *test: Non-existent domain. Do the echo test and you'll see * has not been changed because there is no match.
The third example 'escapes' the special meaning of * so it will be passed exactly as typed to nslookup.
Bill Hassell, sysadmin