4

I have an existing php web application, I'm on IPv4, how can I fake IPv6 address to test the application compatibility with it? or is there a better way to test IPv6 compatibility?

Update: My application log the ip of the user when he's making certain actions. The IP addresses are stored in the database (from another question I can understand that BINARY is the best column type). The application should also be possible to search by IP.

I want apache / php to work as if I were using IPv6, I need to be sure my application compatibility with IPv6 is ready for production on both IPv4 networks + IPv6 networks.

berebidahoo
  • 176
  • 1
  • 6
  • check if your PHP was **not** compiled with `--disable-ipv6` – Gordon Feb 16 '12 at 23:21
  • The application is for multiple clients, some of them asked that I'll make the script IPv6 compatible, they are moving to IPv6 in the near future – berebidahoo Feb 16 '12 at 23:31

4 Answers4

5

I agree with Topener; don't worry about it, your website will run fine with IPv6. You don't need to worry about apache or PHP either, they will run fine.

You should only care about storing IPv6 addresses in a database etc. Make sure you can store them in a proper way and that your database can handle an IPv6 address.

You can simply change $_SERVER['REMOTE_ADDR'] to an IPv6 address:

echo $_SERVER['REMOTE_ADDR']; // will give you your current IP (probaply IPv4)

// change the REMOTE_ADDR to an IPv6 address
$_SERVER['REMOTE_ADDR'] = '3ffe:6a88:85a3:08d3:1319:8a2e:0370:7344';

You can find additional information about storing IPv6 addresses into a database here:

How to store IPv6-compatible address in a relational database

Community
  • 1
  • 1
Mark
  • 2,714
  • 1
  • 14
  • 17
  • Are you sure just modifying $_SERVER['REMOTE_ADDR'] in the start of the application will be enough? no side effects with cookies, ajax, whatever? – berebidahoo Feb 17 '12 at 12:28
  • and about storing ipv6 in database I would also suggest readers to read these: http://stackoverflow.com/questions/420680/how-to-store-ipv6-compatible-address-in-a-relational-database & http://stackoverflow.com/questions/7628528/storing-retrieving-ipv4-ipv6-addresses-in-mysql & http://stackoverflow.com/questions/6242738/detecting-an-ipv6-address-in-php-and-storing-it-properly-in-mysql-how – berebidahoo Feb 17 '12 at 12:29
  • As far as I know cookies and ajax aren't influenced by IP. – Mark Feb 17 '12 at 13:23
0

Also note that for comparing IPv6 adresses, string comparison is not enough. There are different representations of the same IP adress, for example 2001:0DB8:0:0:1::1 is the short form of 2001:0db8:0000:0000:0001:0000:0000:0001.

giraff
  • 4,601
  • 2
  • 23
  • 35
0

Your website will run fine with IPv6. The only thing you need to test is, if you are storing IPv6, or logging of some kind, you should store it properly. To fake this, just enter some variable and put it to the database, or whatever you want to do with it.

An example: 2001:db8::1:0:0:1 and 2001:0DB8:0:0:1::1 and fe80::202:b3ff:fe1e:8329

Otherwise, don't worry about it!

Rene Pot
  • 24,681
  • 7
  • 68
  • 92
  • I want apache / php to work as if I were using IPv6, I need to be sure my application compatibility with IPv6 is ready for production on both IPv4 networks + IPv6 networks – berebidahoo Feb 16 '12 at 23:32
0

If your application logs IP addresses then make sure that the fields to store them are big enough. Make sure that any application that processes those logs knows how to deal with IPv6 addresses. If you need to search for addresses by block/range you should use appropriate storage types for that. If you do access control based on IP address then it becomes a bit more difficult because IPv6 clients might change their source address often when they have privacy extensions enabled, so you might want to allow access per /64 instead of per separate address.

And most important: test, test, test :-)

Community
  • 1
  • 1
Sander Steffann
  • 9,509
  • 35
  • 40