LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2006, 11:19 PM   #1
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Rep: Reputation: 31
Can I receive the IPADDRESS also when using $mail command


Hi,
Can I get the IPADDRESS of the sender also when I use the mail command to send a mail..
For eg,
If I send a mail to myself..
$mail abc@xyz.com

When I receive the mail..In the 'From' option I only get to know my machines name..Cant I know the IPADDRESS also....

Thanks
Danish
 
Old 05-03-2006, 12:23 AM   #2
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 3,025

Rep: Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538
If you want to know the ip address of your machine do:

ifconfig eth0

If you want to use email to find out someone's ip address:

Run an apache web server. Put one jpg image on the server. Send the person an email with this in it:

href="http://<your ip address>/<directory jpg is in>"

Then, when the person opens the email, in order to display the image it will access your server. It will just look like a picture to them, but you can look in the apache logs and see what ip accessed that image file. That is how you get an ip if all you know is the email address.
 
Old 05-03-2006, 01:17 AM   #3
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
Yes using your way I can find out the ip address but cant it be done by using the mail command?

As I had earlier said, when I send a mail using the sendmail on my loopback address to my pop account, the From option in the mail that I receive contains just the machine name...Cant I have my IP ADDRESS also listed...

Thanks
Danish
 
Old 05-03-2006, 01:37 AM   #4
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 3,025

Rep: Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538
Post the ip

Quote:
Originally Posted by dsids
Yes using your way I can find out the ip address but cant it be done by using the mail command?

As I had earlier said, when I send a mail using the sendmail on my loopback address to my pop account, the From option in the mail that I receive contains just the machine name...Cant I have my IP ADDRESS also listed...

Thanks
Danish
The ip is in the email header. If you look at the email source you can see it there.
 
Old 05-03-2006, 02:05 AM   #5
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
I found the IP ADDRESS in the source. Thank you very much...But can't that IP somehow be mentioned in the starting of the message body...

Im using thunderbird 1.7....I had to go to view-> and then click on message source..

Danish
 
Old 05-03-2006, 02:06 AM   #6
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
in continuation with the earlier post...

cant the ip address be mentioned by using a flag or something

Danish
 
Old 05-03-2006, 02:32 AM   #7
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Most mail viewers hide some or all of the mail headers, including the IP address.
Simply said, because most users aren't interested in knowing all computers (hops) that the mail
went through before arriving at it's destination.

With some, viewing the headers is an option.
So, I recommend you start looking at Thunderbird's preferences and settings.

However, making the IP address appear in the mail body requires rewriting of the body.
In theory, only the author of the mail is supposed to alter the body.
So, the only valid option is to actually write a line that contains your IP address in your mails.

Having MTAs (like sendmail, postfix, etc) rewrite mail bodies may be possible, but they're designed to work
with mail headers only, so it's not recommended. If you want such automatic rewriting, maybe you can get your MTA to write the IP address in the Subject header (which is always displayed by all mail viewers, including Thunderbird).

Can you please tell us why you want to look at that information?
If you want mail source statistics, you should look at your MTA configuration. If you want to track down the source of a malicious mail, don't rely only on the IP address. Many "attackers" use spoofing or hijacked computers to do their dirty work.
 
Old 05-03-2006, 02:41 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Also, translating IP addresses to hostnames or vice-versa is usually the job of DNS.

So, knowing either of the two, you can get the other one by using command line tools like
nslookup or dig as well.

ie:
nslookup computer.some.domain
 
Old 05-03-2006, 03:36 AM   #9
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
Being a newbie I wrote a simple script which greps a pattern and mails the output. Now my boss says that he wants to view the ip address of the sender along with the machine name which is mentioned..This script is just for the LAN...

Yes I looked up the thunderbird preferences and found out how to check the mail source..Would you know where in sendmail configuration files would this option of IP ADDRESS be
..I use sendmail sendmail-8.13.1-2

Danish
 
Old 05-03-2006, 05:18 AM   #10
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Where does your boss want to see the IP address?
In one of the mail headers? In the mail body?

I often use http://www.skillreactor.org/tutortxt/mailserv.htm as reference, but I'm no sendmail specialist, so I can't help you with it's configuration.
 
Old 05-03-2006, 05:42 AM   #11
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
if you're using a command line mailer and a script to write the body can you not just add in a variable which greps ifconfig for the IP, and then just include that variable in the body of the mailer? Just a guess, never tried it. When the script ran it would resolve the variable, and thunderbird would just get a text string, showing the IP of the machine the mail was composed on.
 
Old 05-03-2006, 05:52 AM   #12
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
My boss wants to see the ip.It can be anywhere ( in the mail header or body)
...For eg...
A normal mail that I receive is of the format:

From abc@xyz.com

But my boss wants that the ip address should be visible in the From fiels or in the mail body...

Thanks for your help and thanks for the reference...

Danish
 
Old 05-03-2006, 05:54 AM   #13
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by ethics
if you're using a command line mailer and a script to write the body can you not just add in a variable which greps ifconfig for the IP, and then just include that variable in the body of the mailer? Just a guess, never tried it. When the script ran it would resolve the variable, and thunderbird would just get a text string, showing the IP of the machine the mail was composed on.
Ill try that out ....

Danish
 
Old 05-03-2006, 06:59 AM   #14
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by ethics
if you're using a command line mailer and a script to write the body can you not just add in a variable which greps ifconfig for the IP, and then just include that variable in the body of the mailer? Just a guess, never tried it. When the script ran it would resolve the variable, and thunderbird would just get a text string, showing the IP of the machine the mail was composed on.

Thanks for the above idea...It works somewhat...

I did
#ifconfig > ifconfig.txt

#cat ifconfig.txt | grep -m1 "inet addr" | cut -d ":" -f2|cut -d " " -f1

Thanks
Danish
 
Old 05-03-2006, 07:14 AM   #15
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
Glad it works, when you say somewhat, it does what you want or it could be better?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix can't receive mail kelper Linux - Software 6 05-17-2004 09:43 PM
Can't receive mail SylCR Linux - Newbie 12 02-06-2004 12:17 PM
cannot receive mail -- mail command andy18 Linux - General 1 09-09-2003 03:13 PM
Users can't receive mail Scotty2435 Linux - General 5 02-14-2002 10:50 PM
Can't get sendmail to receive mail schurma Linux - Networking 4 04-16-2001 06:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration