IP당 네트워크 패킷 속도 모니터링

IP당 네트워크 패킷 속도 모니터링

내 문제는 내 IP가 DOS 공격에 사용되었다는 보고를 받았다는 것입니다. 문제는 어떤 컴퓨터가 감염되었는지 알 수 없고 공격이 더 이상 활성화되지 않는다는 것입니다.

로컬 IP당 패킷 속도를 계산하는 내 라우터(Fedora 실행)용 간단한 Linux 도구가 있습니까? 선택한 상수를 초과하면 쉘 스크립트가 시작됩니까?

참고 또한 로컬 호스트에서 생성된 패킷에도 관심이 있습니다(서버 자체가 해킹된 경우를 대비해).

답변1

그래서 iptables를 사용하여 하나의 솔루션을 알아냈습니다.

# create new chain for every local ip we wanna monitor
iptables -N ip10     
# forward traffic from monitored IP to it's chain "ip10"
iptables -A FORWARD -i myLan -s 192.168.2.10 -o myWan -j ip10  
# trafic from other IP's we trusted we just accept
iptables -A FORWARD -i myLan -o myWan -j ACCEPT
# here we have even better thing than I asked for 
# we can ban the DOS attack before it gets out
# in following line we set maximum 100 packet per second
iptables -A ip10 -m limit --limit 100/s --limit-burst 300 -j ACCEPT
# here we can directly log if above limit is breached
# log will be in /var/log/message and it will contains IP src+dst, src mac and other info
# note limit 3 msg per minute is important to not have too big log file
iptables -A ip10 -m limit --limit 3/m --limit-burst 10 -j LOG --log-prefix 'mylog:' --log-level 4
# finally packets over limit will be discarded
iptables -A ip10 -j DROP

또한 한 IP에서 전송된 패킷과 크기를 확인하고 다음을 호출하여 얻을 수 있습니다.

iptables -L ip10 -vxn

관심이 있다면 일부 스크립트에서 이를 수행하고 초당 패킷 수로 다시 계산해야 합니다.

서버 자체를 모니터링하려면 체인에 대해 유사한 접근 방식을 수행해야 합니다.

iptables -A OUTPUT

Fedora 18에서 테스트했습니다. 다른 컴퓨터를 공격하려고 시도했는데 패킷이 실제로 중지되었습니다. :)

답변2

이는 일반적인 시나리오입니다.넷플로우. 이는 멋진 그래프로 평가하고 볼 수 있는 주소, 프로토콜 및 포트로 분류된 트래픽에 대한 기록 데이터를 제공합니다.

관련 정보