/* out must be at least `size * 4 + 1` bytes long */ staticvoid escape_str(char *out, constchar *in, size_t size)
{ staticconstchar *hex = "0123456789ABCDEF";
size_t i;
SYS(out, "ip link add tmp0 type veth peer name tmp1");
SYS(out, "ip link set tmp1 netns synproxy");
SYS(out, "ip link set tmp0 up");
SYS(out, "ip addr replace 198.18.0.1/24 dev tmp0");
/* When checksum offload is enabled, the XDP program sees wrong * checksums and drops packets.
*/
SYS(out, "ethtool -K tmp0 tx off"); if (xdp) /* Workaround required for veth. */
SYS(out, "ip link set tmp0 xdp object xdp_dummy.bpf.o section xdp 2> /dev/null");
ns = open_netns("synproxy"); if (!ASSERT_OK_PTR(ns, "setns")) goto out;
SYS(out, "ip link set lo up");
SYS(out, "ip link set tmp1 up");
SYS(out, "ip addr replace 198.18.0.2/24 dev tmp1");
SYS(out, "sysctl -w net.ipv4.tcp_syncookies=2");
SYS(out, "sysctl -w net.ipv4.tcp_timestamps=1");
SYS(out, "sysctl -w net.netfilter.nf_conntrack_tcp_loose=0");
SYS(out, "iptables-legacy -t raw -I PREROUTING \
-i tmp1 -p tcp -m tcp --syn --dport 8080 -j CT --notrack");
SYS(out, "iptables-legacy -t filter -A INPUT \
-i tmp1 -p tcp -m tcp --dport 8080 -m state --state INVALID,UNTRACKED \
-j SYNPROXY --sack-perm --timestamp --wscale 7 --mss 1460");
SYS(out, "iptables-legacy -t filter -A INPUT \
-i tmp1 -m state --state INVALID -j DROP");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.