# hosts.allow with dynamic ip

## iarwain

Hi,

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

```
sshd:myip.dyndns.org
```

And hosts.deny:

```
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.

----------

## magic919

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

----------

## iarwain

Thanks for your reply magic919.

I've made 2 little scripts to make the job.

/usr/bin/act_ips :

```
#!/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 :

```
#!/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 :

```
/usr/bin/ren_ips &
```

And it works  :Very Happy: 

----------

## magic919

Sounds like that will do the job.

T

----------

