does the user login restriction based on IP address support ipv6 for web application?

312 Views Asked by At

Does any one know how to restrict the user to login based on an IPV6 address for a web application in c# dot net?

I have already done the functionality using IPV4 and it's working fine, but I wanted to restrict the user based on their IPV6 for the web application.

Is this possible?

1

There are 1 best solutions below

0
On

In general, yes you can get client IPv6 address via C# code and implements IPv6 restrictions with using HttpRequest.UserHostAddress as mentioned in this question or more accurate with using HTTP_X_FORWARDED_FOR server variable as described in here. If request is made via IPv6 you will have this IP in HTTP_X_FORWARDED_FOR server variable.

You can also use IIS IP address restriction module to configure IPv4 or IPv6 restrictions. Of cause your server application should be configured to work with IPv6.

Take also into account that in Internet mostly you can get IP given by your Internet provider, not real client machine IP. In local networks apparently you can see real IP. It's the same like you see your IP address here, it is different that you see in ipconfig or ifconfig commands.