Go Back   The macosxhints Forums > OS X Help Requests > Networking



Reply
 
Thread Tools Rate Thread Display Modes
Old 09-06-2003, 07:46 AM   #1
sAMANOSKe
Triple-A Player
 
Join Date: Jan 2002
Location: .-tHE mOON-.
Posts: 70
Question adv. IP report

Hi,

I browsed through several threads and hints concerning how to report your IP to an e-mail account / FTP server and I also checked several IP-Reporting utilities but they do not fulfil my needs.

1) Check if DHCP is up, if not release and re-init the DHCP, if IP has changed ->2
2) Report IP to an FTP.server

does any1 know how to script this so cron could run it !?

well here is why ...

The problem with my ISP (Cable) is that from time to time (weekly) they shutdown a router or something so my DCHP lease is dropped and OS X is assigning an ip itself (169.xx.xx.xx). No Problem if I am around. But what if I am away ? Even-worse they changed afterwards my IP to something different ...
sAMANOSKe is offline   Reply With Quote
Old 09-06-2003, 07:57 AM   #2
sAMANOSKe
Triple-A Player
 
Join Date: Jan 2002
Location: .-tHE mOON-.
Posts: 70
Ok I know how to renew the DHCP,

sudo ipconfig set en0 BOOTP
sudo ipconfig set en0 dhcp

but I have no idea how to compare the ip
sAMANOSKe is offline   Reply With Quote
Old 09-06-2003, 09:17 AM   #3
yellow
Moderator
 
Join Date: Jan 2002
Posts: 10,677
Are you sure your firewall isn't blocking the BootP DHCP renew request replies?
yellow is offline   Reply With Quote
Old 09-06-2003, 10:27 AM   #4
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
why bother comparing the IP? just splat it up and drive on.
mervTormel is offline   Reply With Quote
Old 09-06-2003, 01:01 PM   #5
sAMANOSKe
Triple-A Player
 
Join Date: Jan 2002
Location: .-tHE mOON-.
Posts: 70
Well, I am pretty sure the DHCP request is not blocked by my Firewall, because after renewing the DHCP request. I have my old IP address again. From time to time my ISP decides to change my IP.

Quote:
Originally posted by mervTormel
why bother comparing the IP? just splat it up and drive on.

Well, if the connection is dropped and I don't get a new IP I have the 169.xx.xx.xx (selfasigned one) - which I can not post, obviously. Then and only then I need to renew the DHCP (happens from time to time that I need to renew the DHCP 4-5 times). So in fact I have to check whether my IP is 169.xx.xx.xx and then renew until I have a 81.xx.xx.xx. But you are right as soon as I have a valid I don't have to compare but simply "splat it up"
sAMANOSKe is offline   Reply With Quote
Old 09-06-2003, 03:25 PM   #6
sAMANOSKe
Triple-A Player
 
Join Date: Jan 2002
Location: .-tHE mOON-.
Posts: 70
Ok .. after a small fight with the csh shell, and I have to admit the Manuals on the net are very helpful - I succeeded

what do you think to my little script ...

#!/bin/csh

ipconfig getifaddr en0 > IP
set uno = `awk -F . '{print $1}' IP`
echo $uno" as first IP Numba"

if ( $uno == '192') then
echo "We Are Laned"
else if ( $uno == '169') then
echo "We don't have a DHCP Connection"
echo "tryin to re-establish"
while ( $uno == '169')
sudo ipconfig set en0 BOOTP
echo "tryin to reach DHCP Server in few sex"
sleep 3
sudo ipconfig set en0 DHCP
sleep 12
ipconfig getifaddr en0 > IP
set uno = `awk -F . '{print $1}' IP`
end
echo "We have a Connection back"
echo "Copying IP to FTP Server"
ncftpput -E -u <Login> -p <Password> <Ftp.Server> <ServerFolder:/IP/> <File:IP>
endif


ofcorse I get rid of the echos for the the final-cron-job-script but they helped to script it
sAMANOSKe is offline   Reply With Quote
Old 09-06-2003, 03:59 PM   #7
yellow
Moderator
 
Join Date: Jan 2002
Posts: 10,677
Quote:
Originally posted by sAMANOSKe
Well, I am pretty sure the DHCP request is not blocked by my Firewall, because after renewing the DHCP request. I have my old IP address again. From time to time my ISP decides to change my IP.

Does 'Form time to time' happen to coincide with the DHCP lease renewal time?

A 169.foo address is what the machine resorts to when a DHCP renew request is not answered. I'd make sure that you're allowing UDP packets from the DHCP server's port 67 to your your port 68.
yellow is offline   Reply With Quote
Old 09-07-2003, 05:39 AM   #8
sAMANOSKe
Triple-A Player
 
Join Date: Jan 2002
Location: .-tHE mOON-.
Posts: 70
Quote:
Originally posted by yellow
Does 'Form time to time' happen to coincide with the DHCP lease renewal time?

sorry I don't understand
sAMANOSKe is offline   Reply With Quote
Old 09-07-2003, 07:42 AM   #9
yellow
Moderator
 
Join Date: Jan 2002
Posts: 10,677
An IP address assigned by a DHCP server has a 'lifespan'. Minutes, hours, days. For example, 3 days. I turn my computer on today at 10 AM, at 10AM 3 days later, my computer knows that the lifespan alloted for it's IP address is up and that it needs to request a renewal of that lifespan or a new address. If the local firewall is blocking the reply from the router/DHCP server, then the request goes out and is never 'answered' according to the computer and it'll assign itself a 169.foo address.

I was curious if "From time to time" was a reproducible timeframe that you might not have noticed before because you weren't looking for it.

Last edited by yellow; 09-07-2003 at 07:44 AM.
yellow is offline   Reply With Quote
Old 09-07-2003, 02:00 PM   #10
sAMANOSKe
Triple-A Player
 
Join Date: Jan 2002
Location: .-tHE mOON-.
Posts: 70
no .. it has a random behaviour. Stood online for weeks and another day the DHCP got dropped after a few hours ...
sAMANOSKe is offline   Reply With Quote
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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 07:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.