An amount you recommend because the maximum size for any database column storing client ip addresses? I've it set to 16 at this time, but tend to I recieve an ip that's more than by using IPv6, etc?

For IPv4, you could pull off storing some raw bytes from the Ip (each one of the amounts between your periods within an Ip are -255, i.e., one byte). However you would need to translate going interior and exterior the DB and that is untidy.

IPv6 addresses are 128 bits (instead of 32 items of IPv4 addresses). They're usually written as 8 categories of 4 hex numbers separated by colons: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Should you made your area 39 figures you'd be completely looking for IPv6

If you wish to handle IPV6 in standard notation you will find 8 categories of 4 hex numbers:


39 figures.

Children somebody who has attempted everything 3 ways... only use a varchar(39)

The slightly less capable storage far exceeds any advantage of needing to convert it on place/update and format it when showing it anywhere.

As referred to within the IPv6 Wikipedia article,

IPv6 addresses are usually written as eight categories of four hexadecimal numbers, where each group is separated with a colon (:)

An average IPv6 address:


This really is 39 figures lengthy. IPv6 addresses are 128 bits lengthy, which means you could certainly make use of a binary(16) column, however i think I'd stay with an alphanumeric representation.

There is a caveat. For IPv4 planned IPv6 addresses, the string could be more than 39 figures. Allow me to show by having an example:

IPv6 (39 bytes) :


IPv4-planned IPv6 (45 bytes) :


The final 32-bits (that match IPv4 address) can require more than 10 figures.

The right maximum IPv6 string length, therefore, is 45.

It was really a quiz question within an IPv6 training I attended. (All of us clarified 39!)

IPv4 uses 32 bits, as:

I guess it is dependent in your datatype, whether you are just storing like a string having a CHAR type or maybe you are utilizing a statistical type.

IPv6 uses 128 bits. You will not have Insolvency practitioners more than that unless of course you are including additional information together.

IPv6 is arranged into teams of 4 hex numbers seperated by colons, like (from wikipedia):


You are safe storing it as being a 39-character lengthy string, should you want to achieve that. You will find other shorthand methods to write addresses too though. Teams of zeros could be cut down to some single , or teams of zeroes could be hidden completely with a double colon.

If you're just storing it for reference, you are able to store it as being a string, but when you need to perform a research, for instance, to ascertain if the Ip is within some table, you'll need a "canonical representation." Transforming the whole factor to some (large) number may be the right factor to complete. IPv4 addresses could be saved like a lengthy int (32 bits) but you'll need a 128 bit number to keep an IPv6 address.

For instance, each one of these strings are actually exactly the same Ip: 127...1,, ::1, :::::::1