Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
hosts.allow with dynamic ip
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
iarwain
Apprentice
Apprentice


Joined: 25 Sep 2003
Posts: 253

PostPosted: Wed Jul 27, 2005 10:16 am    Post subject: hosts.allow with dynamic ip Reply with quote

Hi,

I want to allow my remote computer (myip.dyndns.org) to access to another[/code] sshd. Here's my hosts.allow:
Code:
sshd:myip.dyndns.org

And hosts.deny:
Code:
sshd:ALL

This way is doesn't work. It seems hosts.allow does not resolve myip.dyndns.org. If I put the ip number manually, it works.

Any ideas?

Thanks.
Back to top
View user's profile Send private message
magic919
Advocate
Advocate


Joined: 17 Jun 2005
Posts: 2182
Location: Berkshire, UK

PostPosted: Wed Jul 27, 2005 7:50 pm    Post subject: Reply with quote

Your method would need it to (from the point of view of the hosts file) ignore the IP of the connecting machine, ignore the fact there is no reverse DNS configured for that IP and then resolve myip.dyndns.org and use that instead. That's why it fails, I'd say.

Tony
Back to top
View user's profile Send private message
iarwain
Apprentice
Apprentice


Joined: 25 Sep 2003
Posts: 253

PostPosted: Fri Jul 29, 2005 11:03 am    Post subject: Reply with quote

Thanks for your reply magic919.
I've made 2 little scripts to make the job.

/usr/bin/act_ips :
Code:
#!/bin/bash

ip1=$(host name1.dyndns.org | awk '{print $4}')
ip2=$(host name2.dyndns.org | awk '{print $4}')
echo "sshd:   localhost,172.26.0.,$ip1,$ip2" > /etc/hosts.allow

/usr/bin/ren_ips :
Code:
#!/bin/bash

while :; do
  /usr/bin/act_ips;
  sleep 300;
done

With the 1st script (act_ips) we update hosts.allow, and with the 2nd (ren_ips) we run the 1st every 300 seconds.

Finally I've added this line to /etc/conf.d/local.start :
Code:
/usr/bin/ren_ips &



And it works :D
Back to top
View user's profile Send private message
magic919
Advocate
Advocate


Joined: 17 Jun 2005
Posts: 2182
Location: Berkshire, UK

PostPosted: Fri Jul 29, 2005 11:51 am    Post subject: Reply with quote

Sounds like that will do the job.

T
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum