Skip to content

Instantly share code, notes, and snippets.

@ngorchilov
ngorchilov / s.php
Last active December 23, 2015 02:59
Kernel auto-port assignment error reproduction
#!/usr/bin/env php
<?php
$broken = TRUE; // TRUE: auto-assign port (doesn't work); FALSE: select port explicitely (works)
$local = TRUE; // TRUE: assing IPs to local interface; FALSE: use TPROXY mode. Doesn't make any difference in kernel behaviour
$ip_range = array('10.254.254.251', '10.254.254.252', '10.254.254.253', '10.254.254.254'); // put minimum two IPs that DO NOT belong to this machine already
$counters = $socks = array();
// constants needed for setting a socket in TPROXY mode
define('SOL_IP', 0);