Jump to content
  • 0

Force Namecheap Module to IPV4 only


MDHMatt

Question

8 answers to this question

Recommended Posts

  • 0
On 8/11/2021 at 9:01 AM, MDHMatt said:

Is there a way to force the namecheap module to use ipv4 only? The api does NOT support ipv6 (verified by namecheap support) and it causing errors when trying to purchase domains.

Use IPv4 in what way? If their API doesn't support IPv6, then they shouldn't have an AAAA record on their DNS for the endpoint, and your server shouldn't try to connect over IPv6. If they do have an AAAA record, and your server has an IPv6 address, removing the IPv6 address should force IPv4.

Link to comment
Share on other sites

  • 0
16 hours ago, Paul said:

Use IPv4 in what way? If their API doesn't support IPv6, then they shouldn't have an AAAA record on their DNS for the endpoint, and your server shouldn't try to connect over IPv6. If they do have an AAAA record, and your server has an IPv6 address, removing the IPv6 address should force IPv4.

Unfortunately I can’t remove the v6 address. The logs looks like we could define an ip to use??

Link to comment
Share on other sites

  • 0

Although this is an old question, I worked around like this:

In components/modules/namecheap/apis/namecheap_api.php

// original code
if (!isset($args['ClientIP'])) {
            $args['ClientIP'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
        }

// added this line:
// I used my own IPv4, but this worked as well (in another panel)

        $args['ClientIP'] = '127.0.0.1';

And yes, namecheap still does not support IPv6.


 

Link to comment
Share on other sites

  • 0
6 hours ago, MDHMatt said:

@Paul can we have a way to enter an ip in the module settings that lets us set the ClientIP? this could be auto populated using the existing code but having an option to adjust it would be great as namecheap get you to whitelist ip address to use the api with and only ipv4

What is the purpose of the ClientIP? Is this the IP address that API calls should originate from , or is it simply passed as a parameter in the API call? I have not looked into this myself. If $_SERVER['REMOTE_ADDR'] is returning an IPv6 address for your server, I can understand the fix posted above to force another IP. However, what are the implications if you enter an invalid IPv4 address, or one that does not resolve to this server? If the IP is just passed along to the API as a parameter, then I suppose it wouldn't cause any communication issues if the IP that made the request were different.

Link to comment
Share on other sites

  • 0
8 hours ago, Paul said:

What is the purpose of the ClientIP? Is this the IP address that API calls should originate from , or is it simply passed as a parameter in the API call? I have not looked into this myself. If $_SERVER['REMOTE_ADDR'] is returning an IPv6 address for your server, I can understand the fix posted above to force another IP. However, what are the implications if you enter an invalid IPv4 address, or one that does not resolve to this server? If the IP is just passed along to the API as a parameter, then I suppose it wouldn't cause any communication issues if the IP that made the request were different.

As per their documentation found here

https://www.namecheap.com/support/api/global-parameters/

and described here

https://www.namecheap.com/support/api/intro/

they use whitelisted ipv4 address to control access to the api which you enter into your account page. Should you enter a non whitelisted ip it gives an error.

this could also be useful for people with multiple IP address who maybe want to limit what ip to use for api calls

Link to comment
Share on other sites

  • 0
On 3/29/2022 at 1:43 PM, pdi said:

Although this is an old question, I worked around like this:

In components/modules/namecheap/apis/namecheap_api.php

// original code
if (!isset($args['ClientIP'])) {
            $args['ClientIP'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
        }

// added this line:
// I used my own IPv4, but this worked as well (in another panel)

        $args['ClientIP'] = '127.0.0.1';

And yes, namecheap still does not support IPv6.


 

@pdiThanks! That’s seem to work

Does this get overwritten when you upgrade??

Link to comment
Share on other sites

  • 0
On 5/28/2022 at 12:53 AM, MDHMatt said:

As per their documentation found here

https://www.namecheap.com/support/api/global-parameters/

and described here

https://www.namecheap.com/support/api/intro/

they use whitelisted ipv4 address to control access to the api which you enter into your account page. Should you enter a non whitelisted ip it gives an error.

this could also be useful for people with multiple IP address who maybe want to limit what ip to use for api calls

Ok, this is unusual because an IP restriction on the API would normally mean that the API would restrict the IP for the source of the request. If you can specify any IP and it uses that, it could be spoofed to bypass the check. It doesn't make sense. I think the 1st comment in that documentation you linked sums it up well:

Quote

Can anybody explain my WHY ClientIp must be included in request? NameCheap API server already knows which IP calls it from, right? It is not only data redundancy, it's error-prone misconception. Client should authenticate itself (username+token), API server should check if remote IP is on the whitelist, configured on NameCheap's side.

It seems to me that this is something Namecheap should fix. Adding a field to specify the IP is a pretty hacky-fix.

The example in this thread of using an IP address of 127.0.0.1 for ClientIP, does this work universally? If so, the simpler solution may be to just specify 127.0.0.1 for ClientIP in all requests like the example code, rather than requesting it. OR, if the IP address = IPv6, then instead of using that address, send 127.0.0.1. Thoughts?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...