LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 07-25-2005, 06:24 AM   #1
paddyjoy
Member
 
Registered: Apr 2005
Location: Sydney
Distribution: FC5
Posts: 174

Rep: Reputation: 30
IP Address


Does anyone have any ideas how I can use script to obtain the IP address of the machine it is run on? I have looked through the bash environment variables but can't find anything that might help. Basically I have a dynamic IP with my ISP and I'm trying to write a script that will ftp my ip address in a txt to a different location every hour or so.

Paddy
 
Old 07-25-2005, 06:46 AM   #2
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
To get your IP address from cli >
lynx -dump http://whatismyip.com | awk '/Your/ {print $4}'
 
Old 07-25-2005, 06:56 AM   #3
Razze
Member
 
Registered: Dec 2004
Location: Espoo, Finland
Distribution: Gentoo, 2.6.16-gentoo-r11
Posts: 108

Rep: Reputation: 15
You can also take a look at www.dyndns.org. There you can link a dynamic ip to a static computer name.
 
Old 07-25-2005, 07:05 AM   #4
paddyjoy
Member
 
Registered: Apr 2005
Location: Sydney
Distribution: FC5
Posts: 174

Original Poster
Rep: Reputation: 30
Thanks for the help. I have edited your command slightly so that I can get the ip address from the output of the ifconfig command like this.

Code:
ifconfig eth1 | awk '/Bcast/ {print $3}' | tail -c 15
Paddy
 
Old 07-25-2005, 07:20 AM   #5
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
That wouldn't do me any good.
Code:
mingdao@james:~$ /sbin/ifconfig eth0 | awk '/Bcast/ {print $3}' | tail -c 15
:192.168.1.255
 
Old 07-25-2005, 07:54 AM   #6
paddyjoy
Member
 
Registered: Apr 2005
Location: Sydney
Distribution: FC5
Posts: 174

Original Poster
Rep: Reputation: 30
Yeah I suppose if you are behind a router it wouldn't be much use but in my case my computer is plugged directly into my modem so works for me.

Paddy
 
  


Reply



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
dhcp no ip address and netmask dont match route address pengy666 Linux - Wireless Networking 1 05-08-2005 09:33 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 10:33 AM
problem to print source address and destination address jooboo Programming 2 11-26-2003 03:24 PM
Should i use the eth0 ip address of my internet ip address when applying iptables ForumKid Linux - Security 2 01-03-2002 08:54 AM

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

All times are GMT -5. The time now is 02:41 AM.

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
Open Source Consulting | Domain Registration