Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Deploying IPv6 (PHP Tek 2016)

Deploying IPv6 (PHP Tek 2016)

Many developers are stuck in the world of old-school IPv4 because it is an easy, comfortable place to be! However, IPv4 is not long for this world. Major network allocations have already run dry, and broadband and 4G mobile networks are steadily expanding the availablility of native IPv6 connectivity. This talk covers the basics of understanding IPv6, what you need to do to get your services working on IPv6, and the changes you need to make in your PHP apps and related services to accomodate IPv6.

This talk was given on May 27th 2016 at PHP Tek 2016.

Please leave feedback at https://joind.in/talk/a6eb9

Marcus Bointon

May 27, 2016
Tweet

More Decks by Marcus Bointon

Other Decks in Technology

Transcript

  1. Marcus Bointon: IPv6
    Marcus Bointon
    Technical director,
    Synchromedia Limited &
    Smartmessages.net
    Deploying IPv6

    View Slide

  2. Marcus Bointon: IPv6
    What is IP?
    ̣Acronym for Internet Protocol
    ̣Low-level networking protocol
    ̣Underlies many other protocols - OSI model
    ̣TCP & UDP
    ̣HTTP, SMTP, FTP, DNS etc
    ̣Provides addresses that identify individual devices
    ̣It’s the stuff the internet is made of

    View Slide

  3. Marcus Bointon: IPv6
    The past - IPv4
    ̣Mature, stable - RFC791 1981!
    ̣It’s been awesome!
    ̣32-bit addressing
    ̣~4 billion addresses
    ̣We have run out of IPv4 addresses
    ̣Ugly workarounds

    View Slide

  4. Marcus Bointon: IPv6
    The present & future - IPv6
    ̣Mature, stable - RFC2460 ratified in 1998!
    ̣Streamlined protocol headers - bigger but simpler
    ̣Stateless autoconfiguration
    ̣Built-in security (IPSec)
    ̣Jumbograms to reduce overhead - 4Gb packets!
    ̣Unicast / Multicast / Anycast
    ̣More stuff that you don’t need to care about…
    ̣128-bit addressing

    View Slide

  5. Marcus Bointon: IPv6
    128 bits gives you…
    340,282,366,92
    0,938,463,463,3
    74,607,431,768,
    211,456

    View Slide

  6. Marcus Bointon: IPv6
    So how big is that?
    ̣With a 0.25mm pixel to display each available address,
    how big an area would you need to display them all?
    ̣IPv4: about the size of a tennis court
    ̣IPv6: 100,000 times the size of the solar system
    ̣A ratio a million billion billion times bigger than a
    drop of water to all the world’s oceans
    ̣So yes, it’s big!

    View Slide

  7. Marcus Bointon: IPv6
    Why IPv6?
    ̣IPv4 is just not enough for tomorrow’s internet
    ̣IoT expected to reach 50 billion devices by 2020
    ̣Bigger, faster, simpler, more scalable, more secure
    ̣IPv6-only networking is mandatory for iOS apps
    ̣It’s much less scary than you think
    ̣You won’t have to change again!

    View Slide

  8. Marcus Bointon: IPv6
    IPv6 Address Allocation
    ̣Just like IPv4, but bigger
    ̣Your ISP will probably give you a /64 subnet
    ̣So you have 4 billion internets to pick your
    own addresses from!
    ̣Great for virtual hosting, SSL, docker containers
    ̣DNS becomes more critical

    View Slide

  9. Marcus Bointon: IPv6
    IPv6 Notation
    ̣We’ve got very used to IPv4’s decimal dotted-quad
    pattern: 192.168.0.1
    ̣That’s just not practical for IPv6
    ̣Hexadecimal for greater density
    ̣Colons to delimit 16-bit chunks for readability
    ̣Square brackets to make it unambiguous
    ̣[2001:0000:0000:EF22:0000:1234:5678:0001]

    View Slide

  10. Marcus Bointon: IPv6
    IPv6 Notation Shortcuts
    ̣It’s all about the zeros
    ̣Replace one sequence of 0000 chunks with a double-
    colon ::
    ̣Collapse other 0000 chunks to 0
    ̣Strip leading zeros: 0023 -> 23
    ̣e.g. 2001:0000:0000:EF22:0000:1234:5678:0001
    ̣Simplifies to 2001::EF22:0:1234:5678:1

    View Slide

  11. Marcus Bointon: IPv6
    Familiar Addresses
    ̣IPv4 Localhost: 127.0.0.1
    ̣IPv6 localhost:
    [0000:0000:0000:0000:0000:0000:0000:0001]
    ̣Becomes simply: [::1]
    ̣All addresses: [::], like 0.0.0.0
    ̣Link-local addresses [FE80…] like 169.254.0.0/16
    ̣CIDR-style networks: [2001::EF22:0:1234:5678:0/96]
    ̣IPv4 mapped [::FFFF:192.168.0.1]

    View Slide

  12. Marcus Bointon: IPv6
    IPv6 in Linux
    ̣Add an IPv6 address dynamically using iproute2:
    ̣ip -6 addr add 2a00:1098:0:80:1000:2a:f:1/64
    dev eth0
    ̣Add it to /etc/network/interfaces - no need for alias
    ̣iface eth0 inet6 static

    address 2a00:1098:0:80:1000:2a:f:1

    netmask 64
    ̣Check it with ip a

    View Slide

  13. Marcus Bointon: IPv6
    IPv6 in PHP
    ̣PHP and all host OSs have full IPv6 support
    ̣PHP shows support in phpinfo()
    ̣Provide IPv6 addresses in square brackets for network
    functions
    ̣e.g. fsockopen(‘tcp://[fe80::1]', 80…);
    ̣Change validations to allow IPv6:

    FILTER_VAR_IPV6, FILTER_FLAG_NO_PRIV_RANGE

    View Slide

  14. Marcus Bointon: IPv6
    IPv6 in MySQL
    ̣If you’re using strings for storing IPs, stop it now!
    ̣UNSIGNED INT for IPv4
    ̣Use MySQL 5.6+
    ̣Use VARBINARY(16) for an elegant, unified solution for both
    IPv4 and IPv6 in the same field
    ̣Convert to / from strings with INET6_ATON and INET6_NTOA
    ̣Similar PHP functions inet_ntop and inet_pton, with one
    function wrapper needed

    View Slide

  15. Marcus Bointon: IPv6
    IPv6 in MySQL
    http://php.net/inet-ntop
    ̣Convert IPv4 or IPv6 from MySQL binary
    format to a string
    function inet6_ntop($ip) {

    $l = strlen($ip);

    if ($l == 4 or $l == 16) {

    return inet_ntop(pack('A'.$l, $ip));

    }

    return '';

    }

    View Slide

  16. Marcus Bointon: IPv6
    Deploying IPv6 - Networking
    ̣Servers need IPv6 addresses
    ̣Your ISP must support it
    ̣or you can tunnel until they do
    ̣Hurricane Electric, SixXS, or your ISP
    ̣Amazon EC2 doesn’t do IPv6, but can via ELB
    ̣Clients need IPv6 addresses
    ̣All 4G mobiles support IPv6 by definition

    View Slide

  17. Marcus Bointon: IPv6
    Deploying IPv6 - DNS
    ̣Name servers on IPv6 (NS/Whois)
    ̣AAAA records in your DNS
    ̣Reverse DNS for mail servers
    ̣Don’t forget SPF
    ̣Check other sources - CDNs too

    View Slide

  18. Marcus Bointon: IPv6
    Testing IPv6
    ̣ip a, ping6, dig aaaa, wget -6
    ̣IPv6 addresses work in /etc/hosts
    ̣https://www.mythic-beasts.com/ipv6/health-
    check
    ̣Chrome/Firefox plugins for connection status -
    IPvFoo

    View Slide

  19. Marcus Bointon: IPv6
    IPv6 Checklist
    ̣Get addresses allocated
    ̣Bring up interfaces
    ̣Listen on IPv6 addresses
    ̣Configure DNS
    ̣Alter apps & databases
    ̣Test!

    View Slide

  20. Marcus Bointon: IPv6
    Questions

    View Slide

  21. Marcus Bointon: IPv6
    Thank you!
    ̣Marcus Bointon
    ̣[email protected]
    ̣@SynchroM
    ̣Synchro on GitHub & Stack Exchange
    ̣https://joind.in/talk/a6eb9

    View Slide

  22. View Slide