# Stop direct IP access, reg via FQDN only

**URL:** <https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752>\
**Category:** Asterisk SIP\
**Created:** [September 20, 2020, 1:25pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752 "2020-09-20T13:25:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ell](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@Ell](https://community.asterisk.org/u/Ell)\
**Post date:** [September 20, 2020, 1:25pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/1 "2020-09-20T13:25:56Z")

</div>

Hi All,

Using Asterisk 16.11.1 (with pjsip) and just wondered if there is a way to stop direct access via the servers IP address and force registration to happen via FQDN only.

Any advice would be much appreciated.

Thanks 😄

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [September 20, 2020, 2:58pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/2 "2020-09-20T14:58:42Z")

</div>

That’s not really something you can do, as a FQDN is resolved to an IP address in order to reach a server.

---

<div class="post-metadata">

**Author:** ![sedwards](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sedwards](https://community.asterisk.org/u/sedwards)\
**Post date:** [September 20, 2020, 4:21pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/3 "2020-09-20T16:21:21Z")

</div>

What are you trying to accomplish?

Keep IP range scanners from finding your server? Maybe a iptables ‘white list’ or fail2ban would be of use?

---

<div class="post-metadata">

**Author:** ![Ell](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@Ell](https://community.asterisk.org/u/Ell)\
**Post date:** [September 20, 2020, 4:43pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/4 "2020-09-20T16:43:07Z")

</div>

Hi All,

thanks for replying so soon 🙂

Should of explained the setup. Am trying to stop a reg happening via IP because i have 2 identical asterisk servers in a failover setup on different public IP address’s. I only want a reg to happen via the FQDN, I don’t want the secondary backup server being used. The FQDN will automatically point to the secondary server when the primary is offline.

I believe this can be done with http with a proxy just wondering if asterisk can do it with SIP -

> <https://stackoverflow.com/questions/29104943/how-to-disable-direct-access-to-a-web-site-by-ip-address>

> **[NGINX – Disable direct access (via http and https) to a website using IP address](https://medium.com/knoldus/nginx-disable-direct-access-via-http-and-https-to-a-website-using-ip-address-9c0e6c7711b6)**
>
> For the requirements wherein direct access to a website using IP address has to be disabled/blocked, following steps can be followed To disable/block direct

Ell 🙂

---

<div class="post-metadata">

**Author:** ![annusfictus](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@annusfictus](https://community.asterisk.org/u/annusfictus)\
**Post date:** [September 20, 2020, 7:09pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/5 "2020-09-20T19:09:33Z")

</div>

As theoretically pjsip support multidomain, if your endpoint is 1000 and your domain is [domain.org](http://domain.org) in a endpoint type block:

type=endpoint

…

With this change, the users can register only over your domain.

---

<div class="post-metadata">

**Author:** ![Ell](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@Ell](https://community.asterisk.org/u/Ell)\
**Post date:** [September 21, 2020, 3:44pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/6 "2020-09-21T15:44:25Z")

</div>

Could you elaborate more or show an example of how this would be written in a pjsip.conf file? it would much appreciated as this issue is something i’ve been trying to solve for a while.

Thanks Ell 🙂

---

<div class="post-metadata">

**Author:** ![annusfictus](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@annusfictus](https://community.asterisk.org/u/annusfictus)\
**Post date:** [September 21, 2020, 4:15pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/7 "2020-09-21T16:15:36Z")

</div>

Somethink Like:

`[````]`  
`type=endpoint`  
`context=internal`  
`disallow=all`  
`allow=ulaw`  
`auth=auth6001`  
`aors=``6001`

`[auth6001]`  
`type=auth`  
`auth_type=userpass`  
`password=``6001`  
`username=``6001`

`[``6001``]`  
`type=aor`  
`max_contacts=``1`

`This configuration had a BUG:`

`The last time I tried it on the latest Asterisk 16 version, works.`

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [October 21, 2020, 4:15pm UTC](https://community.asterisk.org/t/stop-direct-ip-access-reg-via-fqdn-only/85752/8 "2020-10-21T16:15:44Z")

</div>

Closed on October 21, 2020, 4:15pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
