Sponsored Content
Top Forums Shell Programming and Scripting Convert IP address (within a line) to hostname Post 302398738 by scolazz on Thursday 25th of February 2010 12:23:25 PM
Old 02-25-2010
Quote:
Originally Posted by EAGL€
I see two IP addresses coming after "host" in your file, so do you want to get each IP addresses that occurs after each "host" word? Can you illustrate the output you want?
Yes, exactly what I want. Sample output would look something like this:

Code:
access-list acl-secure-out line 2 extended permit tcp host hostname1.example.com object-group ser-secure-bed eq 2049 
access-list acl-secure-out line 2 extended permit tcp host hostname2.example.com host hostname3.example.com eq 2049

The trick here is, some lines have one host, some have two, and others have none. I need all of the lines in the output file though, with just the IPs resolved.

Thanks again!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert ip address to ip number

I want to make a script to read a list of ip addresses from a file then convert those ip addresses to ip number. ip number is made by removing the dots then transfer to a number , so the ip number transfered to binary then to decimal which will represents the ip number 0 : 4294967295 Also I... (17 Replies)
Discussion started by: moutaz1983
17 Replies

2. UNIX for Dummies Questions & Answers

IP address/hostname problem

I have a problem that when I am pinging with the IP address it is giving me whether a server is alive or not but when I am trying it with hostname it is giving unknown host I have checked in /etc/hosts file and the IP address and hostname are both there...still the problem is there.. Can... (1 Reply)
Discussion started by: uLearner
1 Replies

3. Shell Programming and Scripting

Read Hostname and Return IP Address

Dear Experts, I have a text file on my itanium box which contains list of nearly 1000 hostnames. I do not have the IP Address of them. I want read each entry from the text file and want to do a nslookup to the DNS Server and get the IP Adresses and put them in another file in the format... (1 Reply)
Discussion started by: PrasannaKS
1 Replies

4. Shell Programming and Scripting

bash: convert mac address to 16 character format

Hi there Im not quite sure how i can do this, but i am retrieving the mac address from boxes, which in some instances is arriving in its shortened format (i.e. dropping the leading zeros)... for example 0:3:BA:1:E:84 Im trying to figure out a way of converting the single character... (3 Replies)
Discussion started by: rethink
3 Replies

5. UNIX for Dummies Questions & Answers

Routing or Iptables connections by hostname or ip address

edit; I found a solution that works, see thread #3 https://www.unix.com/302417065-post3.html Hi there, I have a small dedicated server that has four ip addresses and by default my httpd sends request using the servers main ip for all outbound connections. I'm quite amateur at routing and... (4 Replies)
Discussion started by: mooofa
4 Replies

6. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

7. UNIX for Dummies Questions & Answers

Solaris - How to get IP Address from a hostname?

We are using Solaris as our database OS. Can you please help me to know how can i get the IP address of a solaris machine in my network from its hostname? e.g. We have a remote database server with the hostname as xyz. Without connecting to the database OS, can i get the IP address of xyz OS from... (1 Reply)
Discussion started by: Anmol Sharma
1 Replies

8. AIX

AIX How to exchange hostname and IP address between two AIX servers?

Hi all, I am trying to exchange hostname and IP address of two AIX machines. But i am confused as how to change it ? do i need to use "smitty mktcpip" or "smitty tcpip" ? what is the difference between smitty mktcpip and smitty tcpip ? Also anymore steps to follow or just updating... (3 Replies)
Discussion started by: lramsb4u
3 Replies

9. AIX

Mutt from address and hostname

Mutt 1.2.3.1i AIX 5.3.12.1 We need to send email to external addresses. But are having problems with the sent-from hostname. They're going out with @server.mycompany.com. We need them to be @mycompany.com. I'm setting from and hostname with -e 'set from="From... (1 Reply)
Discussion started by: Papa Lee
1 Replies

10. Solaris

SMTP relay one (1) hostname with two (2) IP Address

Hi, Anyone can help? Currently : I'm am using a smtp smart relay, 1 hostname but different IP Address 192.168.2.108 and 192.168.2.109). I'm using "smtp.mailhostname.com mailhost" and having an IP Address 192.168.2.108, but there is a certain minutes/seconds that the IP Address will... (2 Replies)
Discussion started by: fspalero
2 Replies
ethers(4)						     Kernel Interfaces Manual							 ethers(4)

NAME
ethers - Database that maps Ethernet addresses to hostnames DESCRIPTION
The /etc/ethers file is used in conjunction with the reverse address resolution protocol daemon (rarpd) to map Ethernet addresses to host- names. It contains information about the known (48-bit) Ethernet addresses of hosts on the Internet. For each host on an Ethernet, a single line should be present in the file with the following information: Ethernet-address official-host-name Items are separated by one or more spaces or tabs. A number sign (#) indicates the beginning of a comment that extends to the end of line. The standard form for Ethernet addresses is: x:x:x:x:x:x The x is a hexadecimal number between 0 and ff, representing 1 byte. The address bytes are always in network order. Hostnames can contain any printable character other than a space, tab, newline, or number sign (#). Hostnames in the /etc/ethers file should correspond to the hostnames in the /etc/hosts file or to those provided by the name service. EXAMPLES
The following is a sample ethers file: 08:00:20:01:e5:1c host1 # Comments go here 08:00:20:01:d0:4c host2 # Comments go here 08:00:20:01:e0:1d host3 # Comments go here 08:00:20:00:c2:4e host4 # Comments go here RELATED INFORMATION
Commands: rarpd(8) Files: hosts(4), packetfilter(7) Routines: ethers(3) delim off ethers(4)
All times are GMT -4. The time now is 09:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy