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?
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 usingHTTP_X_FORWARDED_FOR
server variable as described in here. If request is made via IPv6 you will have this IP inHTTP_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
orifconfig
commands.