Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Setting A Static Ip Address?, For my web server
gangsta_style
post Jan 25 2004, 09:19 PM
Post #1


Grub-er
**

Group: Members
Posts: 36
Joined: 19-October 03
From: Quebec Asti
Member No.: 1,649



Hey,

I have a web site with one of those free redirection urls and cloaking. That address points to my Red Hat 7.3 server. But every few hours the site is "down" because the ip that the url points to is no longer valid. There is this special url that I can visit from that old computer that they put up especially for people with dynamic ip addresses. But my problem it that I don't even shutoff my computer and the IP seems to change for nothing! I don't know if it's a "me" problem or a sympatico problem. Will making a static ip work? I yes, how do I do it?
Go to the top of the page
 
+Quote Post
hughesjr
post Jan 25 2004, 09:40 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



Your external IP (the one given to you by your ISP) is not at all controllable by you. They can expire it and require you to obtain a new one ... but if you keep the computer on, it changes much less frequently.

Do you have a firewall/router (with a internal subnet like 192.168.0 or 10.0.0 behind it on your redhat machine) or is the PC in question connected directly to the internet?

If you have a router and a Windows machine on the inside you can download the program Direct Update to keep the dynamic DNS service updated. I use this to keep several domains updated on www.zoneedit.com. There are also 2 recommended linux clients for zoneedit ... they are zoneclient and DDClient.


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
gangsta_style
post Jan 25 2004, 10:53 PM
Post #3


Grub-er
**

Group: Members
Posts: 36
Joined: 19-October 03
From: Quebec Asti
Member No.: 1,649



I have a D-Link router and a WinXP (my subnet is 192.168.0). And in the settings of the router I can point to a few sites like dynDNS.org.... But I probably need programs. I checked them out pretty quickly... but I think I have another idea! Because my redirection url is from http://www.freedomain.co.nr. They say that all I have to is write this in the address bar: "http://www.freedomain.co.nr/dyna.php?domain=YOU&tld=co.nr&pass=password&dir=sub_dir" and it works all good. I typed it from lynx a few times and my site worked again! So is there a script or program or whatever I can program that can automatically do this, say.. ever hour?
Go to the top of the page
 
+Quote Post
hughesjr
post Jan 26 2004, 08:56 AM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



How often do you need to update their system ... (I know everytime your external IP changes you will need to do an update ... but how often if the IP doesn't change)... looking at the site, I think the answer is at least every 30 days?

So,

We can make you a couple of scripts and run them as crons .... ok try running this at the command line:

CODE
lynx -dump 'http://www.whatismyip.com' | grep -i "your ip is" | /bin/awk '{ print $4 }'


It should tell you your external IP address .... if it works, then we can create a script to check your external IP and see if it has changed. You can run once per day (or hour) ... or more often if you like {but be careful ... the whatsmyip guys might get mad if you do it every 5 minutes, for example}. We will write 2 scripts ... one to check the external IP ... one to update the freedomain.

everything below this line should be done as root

edit a file called /usr/local/bin/check_ext_ip
CODE
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin

# get old external ip
# and set the variable OLD_EXTERNAL_IP
if [ -f /var/log/external_ip ]; then
 OLD_EXTERNAL_IP=`cat /var/log/external_ip`
else
 OLD_EXTERNAL_IP=none
fi

#echo $OLD_EXTERNAL_IP

# get the current external IP
CURRENT_EXTERNAL_IP=`lynx -dump 'http://www.whatismyip.com' | grep -i "your ip is" | /bin/awk '{ print $4 }'`

# if current external ip is null then something is wrong...
if [ "$CURRENT_EXTERNAL_IP"x == x ]; then
 echo "There is a problem, is your internet connection down?"
 exit 1
fi

# check the CURRENT_EXTERNAL_IP against the
# OLD_EXTERNAL_IP, update the /var/log/external_ip
# and the freedomain service if the IP changes
if [ "$OLD_EXTERNAL_IP" != "$CURRENT_EXTERNAL_IP" ]; then
 #echo "IPs don't match"
 echo $CURRENT_EXTERNAL_IP > /var/log/external_ip
 /usr/local/bin/update_freedomain
else
echo "IPs match, nothing to do."
fi


Second file - edit a file name /usr/local/bin/update_freedomain:

CODE
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin

# if there is /var/log/external_ip use it ... otherwise figure out the IP
if [ -f /var/log/external_ip ]; then
 CURRENT_EXTERNAL_IP=`cat /var/log/external_ip`
else
 CURRENT_EXTERNAL_IP=`lynx -dump 'http://www.whatismyip.com' | grep -i "your ip is" | /bin/awk '{ print $4 }'`
 # if current external ip is null then something is wrong...
 if [ "$CURRENT_EXTERNAL_IP"x == x ]; then
   echo "There is a problem, is your internet connection down?"
   exit 1
 fi
fi

lynx -dump 'http://www.freedomain.co.nr/dyna.php?domain=http://$CURRENT_EXTERNAL_IP&tld=co.nr&pass=password&dir=sub_dir' > /var/log/update_freedomain


There are 2 lines in the code that might wrap because of the length (the first line is in each script) ... each line is one single line ... They are:

CURRENT_EXTERNAL_IP=`lynx -dump 'http://www.whatismyip.com' | grep -i "your ip is" | /bin/awk '{ print $4 }'`

lynx -dump 'http://www.freedomain.co.nr/dyna.php?domain=http://$CURRENT_EXTERNAL_IP&tld=co.nr&pass=password&dir=sub_dir' > /var/log/update_freedomain

----------------
I assumed that the YOU in the www.freedomain.co.nr line you used was the updated URL when your address changes ... so in the code I wrote it is http://xxx.xxx.xxx.xxx ... if that is wrong, let me know what YOU is and I'll fix the code.

You need to edit the pass=password and the dir=sub_dir in the file /usr/local/bin/update_freedomain ...

You also need to make each file executeable after you save it:

chmod 755 /usr/local/bin/update_freedomain
chmod 755 /usr/local/bin/check_ext_ip


IF everything is working correctly (make sure we test everything before you do this part), here is how you can check your ip daily (or hourly, if you prefer), update the site if needed ... and set a weekly update even if the IP doesn't change ...so they don't close the account(if we do it monthly, it might go longer than 30 days....)

If the files are now right, lets test them ...

at the command line run (as root):

/usr/local/bin/check_ext_ip

The first time it runs, it should create the file /var/log/external_ip ... let's look at that and make sure it is your external IP ... use the command cat /car/log/external_ip

If that is good, run /usr/local/bin/check_ext_ip ... this time it should say the IPs match ... if so, were are looking good.

Now let's see if the site works .... try browsing to your website name.....

If that works, run the script (from the command line as root):

/usr/local/bin/update_freedomain

After it runs, look at the file /var/log/update_freedomain ... that is the output (as text) of the www.freedomain.co.nr lynx command ... see if it looks like what you expect.

hopefully everything works....

do this as root ... and ONLY after everything is verified working!

go to the directory /etc/cron.daily (or /etc/hourly) and create a link to the file /usr/local/bin/check_ext_ip to check the IP daily (or hourly) ... then go to /etc/cron.weekly and create a link to /usr/local/bin/update_freedomain to do the weekly update (even if the ip didn't change).

Here are the commands:

cd /etc/cron.daily
ln -s /usr/local/bin/check_ext_ip check_ext_ip


cd /etc/cron.weekly
ln -s /usr/local/bin/update_freedomain update_freedomain


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 11th December 2017 - 02:17 AM