• Stars
    star
    317
  • Rank 132,216 (Top 3 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

syn flood protection

syncookied

syncookied logo

Build Status

syncookied emulates linux kernel syncookie functionality by intercepting SYN packets and sending replies to them using the same cookie generation alghorithm. It can achieve better performance under SYN flood attacks thanks to kernel bypass (netmap).

Installation

  1. Install rust (instructions here: https://www.rust-lang.org/en-US/downloads.html)
  2. Install build-essential and libpcap-dev or equivalent package for your distribution
  3. Install netmap. Make sure netmap.h / netmap_user.h can be found in /usr/include. Alternative you can point CFLAGS variable to their location: example.
  4. run cargo build --release, resulting binary will be found in target/release/syncookied.

Note: we use AVX-accelerated SHA1 function by default. SSE3 implementation is also available under sse3 feature flag, i.e.: cargo build --features=sse3 --no-default-features --release.

How to run

On server you want to protect

  1. Install tcpsecrets linux kernel mode to expose tcp syncookie key and timestamp
  2. Start syncookied in server mode: syncookied server <proto://ip:port>. Running this commands automatically starts a TCP or UDP server on specified ip/port and sets net.ipv4.tcp_syncookies to 2 on first request.

On server you want to use for packet processing

  1. Install netmap and make sure it works (pkt-gen)

  2. Disable NIC offloading features on the interface you want to use (eth2 here):

    ethtool -K eth2 gro off gso off tso off lro off rx off tx off 
    ethtool -A eth2 rx off tx off
    ethtool -G eth2 rx 2048 tx 2048
    
  3. Set up queues and affinities. Here we bind 12 queues to first 12 cpu cores:

    QUEUES=12
    ethtool -L eth2 combined $QUEUES
    ./set_irq_affinity -x 0-11 eth2
    

    set_irq_affinity is available at https://github.com/majek/ixgbe/blob/master/scripts/set_irq_affinity

  4. Create hosts.yml file in the working directory, which looks like this

    - ip: 185.50.25.4
      secrets_addr: udp://192.168.3.231:1488
      mac: 0c:c4:7a:6a:fa:bf
    

Here ip is external ip you want to protect, secrets_addr is the address of syncookied server running on protected host, and mac is its MAC address.

  1. Run syncookied -i eth2. It will print something like this:

    Configuration: 185.50.25.4 -> c:c4:7a:6a:fa:bf
    interfaces: [Rx: eth2/3c:fd:fe:9f:a8:82, Tx: eth2/3c:fd:fe:9f:a8:82] Cores: 24
    12 Rx rings @ eth2, 12 Tx rings @ eth2 Queue: 1048576
    Starting RX thread for ring 0 at eth2
    Starting TX thread for ring 0 at eth2
    Uptime reader for 185.50.25.4 starting
    ...
    
  2. Configure your network equipment to direct traffic for protected ip to syncookied.

  3. You can reload configuration at any time by changing hosts.yml and sending HUP signal to syncookied. It will print something like this:

    Uptime reader for 185.50.25.4 exiting
    All uptime readers dead
    Old readers are dead, all hail to new readers
    Uptime reader for 185.50.25.4 starting
    ...
    
  4. Enjoy your ddos protection

Notes

syncookied has some options you may want to tune, see syncookied --help. If you have more than 1 interface on your server, you may want to look into -O to use second one for TX. This greatly improves performance and latency as forwarding and syn-reply traffic is separated.

Traffic filtering

It's possible to filter traffic by adding "filters" section to host configuration like this:

- ip: 185.50.25.4
  secrets_addr: 127.0.0.1:1488
  mac: 0c:c4:7a:6b:0a:78
  filters:
   tcp and dst port 53: drop
   tcp and dst port 22: pass
   default: pass

Filters are written in pcap syntax. Consult pcap-filter(7) for more information. Default policy is "pass". It can be changed by using default key. Note that filtering happens on layer 4.

Troubleshooting

Please check the FAQ before filing an issue.

Need help?

Join us on Telegram: https://telegram.me/syncookied

Performance

syncookied under 12.65 Mpps syn flood attack utilizing 12 cores of Xeon E5-2680v3: syncookied perf

License

syncookied is distributed under the term of GPLv2.

More Repositories

1

sprutio

Beget File Manager App
Python
470
star
2

grpc-to-fpm

GRPC to FPM proxy server
Go
34
star
3

dns-zone-configurator

Php library for parsing and editing dns zones files programmatically with high level abstraction.
PHP
22
star
4

tcpsecrets

Linux kernel module to provide access to tcp secrets via /proc/tcp_secrets
C
16
star
5

sprutio-frontend

Beget File Manager JS Frontend
JavaScript
9
star
6

wakatime-jira-integration

PHP
8
star
7

sprutio-rpc

Beget File Manager RPC server
Python
8
star
8

dns-zone-tokenizer

Dnszone file lexical parser
PHP
6
star
9

antivirus

API for Automatic Virus Healing
5
star
10

sphinx-configurator

Php library for parsing and editing sphinx.conf files
PHP
5
star
11

lanurite

Library for Models and Collection use in JS world. supported browser, Nodejs, TypeScript
TypeScript
4
star
12

domain-registrar

Domain registrar API
4
star
13

php-grpc-client-generator

PHP
4
star
14

ascii-table

Enum of ascii table chars
PHP
3
star
15

ltd-beget.github.io

Beget engineering blog
CSS
3
star
16

yiiic

yii interactive console
PHP
3
star
17

openapi-auth-python

Python
3
star
18

sphinx-configuration-tokenizer

tokenize sphinx configuration and that's all, folks.
PHP
3
star
19

stringstream

Stringstream data structure
PHP
3
star
20

go-acl

Minimal go bindings for linux libacl
Go
2
star
21

bdrm

API for Beget Domain Registration Microservice
2
star
22

openapi-vps-python

Python
2
star
23

auth

API for User Authorization
2
star
24

statistic

Public Statistics API
1
star
25

taskmgr-go

runs commands and stuff
Go
1
star
26

beget_amqp

AMQP server with Workers, Manager, Callbacks and queue by tag
Python
1
star
27

network

API for User Network Managment
Protocol Buffer
1
star
28

besync

Go
1
star
29

beget_msgpack

Based on controllers -> client and server wrappers for msgpack
Python
1
star
30

openssh-key-php

PHP
1
star
31

vps

API for vps manage
1
star
32

beget_amqp_py3

Python
1
star
33

openapi-vps-go

Shell
1
star
34

ftp

Public FTP API
1
star
35

vps-alert

API для svc-vps-alert
1
star
36

information-units

Php structures for standard information units
PHP
1
star
37

go-marisa

Minimal marisa-trie bindings for go
C++
1
star
38

php-vim

Console helper for php to open vim in script, gives it control and returns control to script after close vim
PHP
1
star
39

helpdesk

API for customer ticket system
1
star