Daniel Francis Daniel Francis - 5 months ago 49
Linux Question

Adding an ipv6 address to "require ip" in phpmyadmin.conf in linux

I'm trying to edit

phpMyAdmin.conf
in
etc/httpd/conf.d/phpMyAdmin.conf
such that it only allows an ip.

I have this which works when my router is set to only allow ipv4 addresses:

<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 111.222.333.444
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 111.222.333.444
Allow from ::1
</IfModule>


I want to add an ipv6 address, but it only works when I add an entire ipv6 address (replacing ::1). ie
xxxx:xxxx:xxxx:xxxx:xxxx:b95:bdb0:9c2b


However, my ipv6 address changes on reboot. So I want to add a limited address.

I've tried:

xxxx:xxxx:xxxx?

xxxx:xxxx:xxxx:*

xxxx:xxxx:xxxx/48

and all the variants of the above.

but none work (in fact, phpmyadmin won't restart)

Is there a way to do this? Thanks :)

Answer

The supported syntaxes are, for Apache 2.2 and 2.4 respectively:

Allow from 1111:2222:3333:4444::/64

Require ip 1111:2222:3333:4444::/64

The syntax you were trying was probably missing the terminal ::, which was causing the base IPv6 address to be invalid. (It'd be comparable to trying to write 1.2.3/24 instead of 1.2.3.0/24.)