본문 바로가기

이니미니

iftop 트래픽 모니터링 / ubuntu 본문

linux&server/issue

iftop 트래픽 모니터링 / ubuntu

OYG 2019. 11. 22. 14:58

클릭하여이동


1. 트래픽 모니터링


2. 트래픽 제한



iftop 로 실시간 트래픽을 볼 수 있다.


install

# ubuntu
apt-get install iftop  

use

$ iftop

좌측에는 서버 IP 우측에는 클라이언트 IP 를 보여준다. 우측에 3컬럼은 각각 2초, 4초, 10초 동안의 평균 전송량을 보여준다.

  • TX : 전송
  • RX : 수신
  • TOTAL : 전체
  • cumm : iftop 실행후 현재까지의 총 데이터량
  • peak : 피크시의 데이터
  • rates : 각각 2초, 4초, 10초의 평균흐름

option

$ iftop --help 
Synopsis: iftop -h | [-npblNBP] [-i interface] [-f filter code]  
                               [-F net/mask] [-G net6/mask6]

   -h                  display this message
   -n                  don't do hostname lookups
   -N                  don't convert port numbers to services
   -p                  run in promiscuous mode (show traffic between other
                       hosts on the same network segment)
   -b                  don't display a bar graph of traffic
   -B                  Display bandwidth in bytes
   -i interface        listen on named interface
   -f filter code      use filter code to select packets to count
                       (default: none, but only IP packets are counted)
   -F net/mask         show traffic flows in/out of IPv4 network
   -G net6/mask6       show traffic flows in/out of IPv6 network
   -l                  display and count link-local IPv6 traffic (default: off)
   -P                  show ports as well as hosts
   -m limit            sets the upper limit for the bandwidth scale
   -c config file      specifies an alternative configuration file 

hotkey

  • iftop 을 실행한 상태에서 특정키를 눌러서 아래와 같이 실시간으로 표시를 변경할 수 있다.
f - filtering  
t - rx only | tx only | both  
p - port display  
P - pause  
j/k - scroll up/down  
b - bar graph on/off  
L - lin/log scales  
T - cumulative totals  
n - name resolution  
h - help for more keys and info  

-f 옵션 - ip 필터링

  • 특정 ip로 들어오는 클라이언트에 대해서만 보고 싶을 때가 있다. 예를들면, 10.10.1.175 로 들어오는 ip 만 따로 보고 싶다고 하면 아래와 같이 -f 필터링 옵션을 주면 된다. -f 옵션에 대한 값은 pcap-filter 형식의 필터를 넣어야 한다. 이게 좀 불편한데 대략적인 형식은 아래와 같다.

    • dst host xxxx
    • dst net xxxx
    • dst port xxxx
    • dst portrange start-end
    • src host xxxx
    • src net net
    • src port xxxx
    • src portrange start-end
    • gateway xxxx
    • ip proto protocol
iftop -f 'ip dst 10.10.1.175'  
iftop -i eth0  -f  “dst host Linux.com”  
iftop  -i  eth1   -f    “dst port 22″ 

setting file

  • 설정파일은 ~/.iftoprc 에 저장하면 사용할 수 있고 실행옵션에서 -c 옵션을 이용해서 지정할 수 있다.
  • 자세한 내용은 iftop manpage 을 확인해보자.
# .iftoprc
# config file for iftop
dns-resolution: no  
port-resolution: no  
show-bars: yes  
promiscuous: yes  
port-display: on  
hide-source: no  
hide-destination: no  
use-bytes: yes  
line-display: one-line-both  
show-totals: yes  
log-scale: yes  


'linux&server > issue' 카테고리의 다른 글

traffic shaping(트래픽제한)  (0) 2019.11.22
mysql linux서버 외부접속  (0) 2018.04.06
Comments