Find the answer to your Linux question:
Results 1 to 9 of 9
Hello, I try to forward all the network traffic on specific port from my VPS to home PC. The problem is that I have dynamic IP at home so I've ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    HTF
    HTF is offline
    Just Joined!
    Join Date
    Feb 2011
    Posts
    14

    DNS cache, Dynamic IP


    Hello,

    I try to forward all the network traffic on specific port from my VPS to home PC.

    The problem is that I have dynamic IP at home so I've installed Dynamic Update Client (DUC) from no-ip.com.

    I also use 'redir' software on Centos VPS to redirect the traffic and everything works fine till my ISP change the IP of my home PC.

    Does Centos cache DNS queries by default (nscd is not running)?
    Is there a some way/software that will periodically check if the IP of particular domain has changed and update accordingly.

    Do you know some better way to achieve this?

    I also found something like this:
    hxxp://ipupdate.sourceforge.net/index.html

  2. #2
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,049
    Welcome to the forums!

    When you update your DNS with a service such as no-ip (or any and all other such services) it takes a while for this updated config to spread around the world.

    All the servers that make up the internets DNS sync with each other. And this makes that it can take up to 24 or even as much as 72 hours before all servers know your 'new' IP address. In reality however my experience is that it takes some three/four hours.

    Could it be that this is causing the problem you're having?
    Can't tell an OS by it's GUI

  3. #3
    HTF
    HTF is offline
    Just Joined!
    Join Date
    Feb 2011
    Posts
    14
    Quote Originally Posted by Freston View Post
    Welcome to the forums!

    When you update your DNS with a service such as no-ip (or any and all other such services) it takes a while for this updated config to spread around the world.

    All the servers that make up the internets DNS sync with each other. And this makes that it can take up to 24 or even as much as 72 hours before all servers know your 'new' IP address. In reality however my experience is that it takes some three/four hours.

    Could it be that this is causing the problem you're having?
    Thank you for reply.

    - it's actually works right after reboot so it looks like DNS propagates quite fast

    I think 'redir' just run on the old IP - on which the connection was established initially so I need some way to refresh it.

    Do you know some better way to forward network traffic from one IP to FQDN (no static IP) on specific port

    Maybe local DNS server will help?

  4. #4
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,049
    Quote Originally Posted by HTF
    - it's actually works right after reboot so it looks like DNS propagates quite fast
    Sorry, I'm not sure what you mean by 'it works' or why you'd need a reboot? And what you reboot so that it works?
    Can't tell an OS by it's GUI

  5. #5
    HTF
    HTF is offline
    Just Joined!
    Join Date
    Feb 2011
    Posts
    14
    Quote Originally Posted by Freston View Post
    Sorry, I'm not sure what you mean by 'it works' or why you'd need a reboot? And what you reboot so that it works?
    Sorry for misleading.

    As I mentioned before I use 'redir' to forward traffic, so I created simple rule:

    redir --lport=10000 --laddr=xxx.xxx.xxx.xxx --cport=10000 --caddr=domain.com &
    - and added to /etc/rc.local to start at boot

    - so when I reboot my VPS after the IP of my home PC has been changed by ISP this redirection works again but I think it's not a problem with DNS itself. The reboot just probably reset the connection and forced 'redir' to establish another one with new IP.

  6. #6
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,049
    Ok, but wouldn't that mean that killing and restarting 'redir' would also work?


    I mean, I can imagine redir, upon launch, check the DNS once and keep whatever value for IP address is returned. It probably wont check periodically to see if the value has changed.

    If that is the case, what you need is some process that checks if the IP address tied to your domain name has changed while redir was running, and restart redir so that it picks up the new IP address. I suppose...


    EDIT: Running a local DNS would, IMHO, only make matters worst as that will probably make a cache of it's own and prevent quick updating of the address translation. It could be configured to not do that, but that would defeat the purpose of running a local DNS service.
    Can't tell an OS by it's GUI

  7. #7
    HTF
    HTF is offline
    Just Joined!
    Join Date
    Feb 2011
    Posts
    14
    Ok, but wouldn't that mean that killing and restarting 'redir' would also work?
    Yes, you are right.

    I mean, I can imagine redir, upon launch, check the DNS once and keep whatever value for IP address is returned. It probably wont check periodically to see if the value has changed.

    If that is the case, what you need is some process that checks if the IP address tied to your domain name has changed while redir was running, and restart redir so that it picks up the new IP address. I suppose...
    Exactly but how to achieve this if I'm not to good with scripting.

  8. #8
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,049
    Ok, well advanced bash scripting guide is an excellent resource on scripting.

    What you're looking for is something along these lines (untested!)
    First:
    host $yourdomain|grep address|head -1|awk '{print $4}'>/tmp/mydomain.ipaddress

    Then make a cron job that runs every half hour (or so...)


    Code:
    #!/bin/bash
    echo "This is untested, ugly and probably wont really work; for example purposes only!"
    exit
    
    YOURDOMAIN=yourdomain.name
    TMPFILE="/tmp/mydomain.ipaddress"
    LOGFILE="/tmp/mydomain.log"
    
    OLD_ADDRESS=`	cat	$TMPFILE`
    NEW_ADDRESS=`	host 	$YOURDOMAIN	|\
    		grep	"address"	|\
    		head	-1		|\
    		awk	'{print $4}'	`
    
    if [ "$OLD_ADDRESS" != "$NEWADDRESS" ]
    then
    	echo "$NEW_ADDRESS" > $TMPFILE
    	killall	redir
    
    #	The ampersand is where the magic is. It pushes
    #	redir into a subshell, allowing this script to
    #	continue and exit.
    	redir 	--with-options --with-extras &
    	echo "new address discovered at `date`">$LOGFILE
    else
    	echo "debug info: no changes at `date`">>$LOGFILE
    fi
    Can't tell an OS by it's GUI

  9. #9
    HTF
    HTF is offline
    Just Joined!
    Join Date
    Feb 2011
    Posts
    14
    OK thank you.

    Do you think I can set this up with some VPN configuration or SSH tunnelling?

    I'm not quite sure how to set VPN as it's VPS based on openVZ. It has TUN/TAP enabled and I tried to install vtun but I can't get this to work at all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •