I have a server in my Office which allows connections thru the router from some clients out on the site. This is using fibre broadband Ip v4 and a fixed Ip address and was is working well until broadband went down for for a day.I thought I needed a back up router connected to 4G and then I could switch the server to use the 4G router and get my client connected again. 4 G is usually dyamic IP Address so I decided to write a little function to check the ipaddress of the 4G router every 60 seconds and post it to a service on the cloud so that my clients could read the ip address from that service and connect to my server.I was going to use this from so:
https://stackoverflow.com/questions/3253701/get-public-external-ip-address
public static void Main(string[] args)
{
string externalip = new WebClient().DownloadString("http://icanhazip.com");
Console.WriteLine(externalip);
}
This seems fine and I get something like 81.123.432.34 etc back from the service. I connected to my 4G router and I got an IP V6 address back like this :
2a01:4c8:41d:6c29:b1a2:69ef:18f4:4aa4
Can I still use the router ? What ipaddress would I put on the clients? Is it ok for c# sockets to use v6 address?
You can use the IPv6 address if both ends of your connection have IPv6 connectivity. Most 4G LTE providers offer IPv6 because LTE requires IPv6, but your landline ISP might not yet offer it.
If you need to distinguish between IPv4 and IPv6, you'll need to use an IP address service that allows you to query them separately. When i also had this need and did not find one already existing, I wrote my own which you can find at https://myip.addr.space/ .