회원 로그인
정보기억 정보기억에 체크할 경우 다음접속시 아이디와 패스워드를 입력하지 않으셔도 됩니다.
그러나, 개인PC가 아닐 경우 타인이 로그인할 수 있습니다.
PC를 여러사람이 사용하는 공공장소에서는 체크하지 마세요.
소셜네트워크 서비스를 통해서 로그인하시면 별도의 로그인 절차없이 회원서비스를 이용하실 수 있습니다.


최근 게시물

1.노션에서 작성 중

1.노션에서 작성 중

개편하기 전까지 노션에서 작성 중

2024.04.04//read more

2.ChatGPT

2.ChatGPT

OpenAI로 대규모 언어 모델대화형...

2023.03.16//read more

3.노코딩 게임 엔진 - 빌..

3.노코딩 게임 엔진 - 빌..

빌드 지원안드로이드iOS윈도우즈특이사...

2023.03.14//read more

4.(완료) 미접속 회원 정..

4.(완료) 미접속 회원 정..

[완료] 36명의 회원을 정리하였습니...

2023.02.16//read more

5.매뉴얼 플러스 - 전자제..



안정적인 DNS 서비스 DNSEver
DNS Powered by DNSEver.com


tc 명령어를 이용한 트래픽 제한 스크립트

푸딩뱃살 | 2015.03.07 18:44 | 조회 6440
tc 명령어를 이용한 트래픽 제한하기


설정은 아래만 수정하면 된다.

IF=eth0 #랜카드명, 주로 eth0 이름을 주소 사용
DNLD=1mbit #다운로드 제한, 단위 MB
UPLD=1mbit #업로드 제한, 단위 MB
IP=xxx.xxx.xxx.xxx #IF에 설정된 호스트 IP

tc.sh로 저장하고, 실행은
tc.sh start    #시작
tc.sh stop    #중지
tc.sh restart    #재시작
스크립트
#!/bin/bash
#
#  tc uses the following units when passed as a parameter.
#  kbps: Kilobytes per second 
#  mbps: Megabytes per second
#  kbit: Kilobits per second
#  mbit: Megabits per second
#  bps: Bytes per second 
#       Amounts of data can be specified in:
#       kb or k: Kilobytes
#       mb or m: Megabytes
#       mbit: Megabits
#       kbit: Kilobits
#  To get the byte figure from bits, divide the number by 8 bit
#

#
# Name of the traffic control command.
TC=/sbin/tc

# The network interface we're planning on limiting bandwidth.
IF=eth0             # Interface

# Download limit (in mega bits)
DNLD=1mbit          # DOWNLOAD Limit

# Upload limit (in mega bits)
UPLD=1mbit          # UPLOAD Limit

# IP address of the machine we are controlling
IP=xxx.xxx.xxx.xxx     # Host IP

# Filter options for limiting the intended interface.
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"

start() {

# We'll use Hierarchical Token Bucket (HTB) to shape bandwidth.
# For detailed configuration options, please consult Linux man
# page.

    $TC qdisc add dev $IF root handle 1: htb default 30
    $TC class add dev $IF parent 1: classid 1:1 htb rate $DNLD
    $TC class add dev $IF parent 1: classid 1:2 htb rate $UPLD
    $U32 match ip dst $IP/32 flowid 1:1
    $U32 match ip src $IP/32 flowid 1:2

# The first line creates the root qdisc, and the next two lines
# create two child qdisc that are to be used to shape download 
# and upload bandwidth.
#
# The 4th and 5th line creates the filter to match the interface.
# The 'dst' IP address is used to limit download speed, and the 
# 'src' IP address is used to limit upload speed.

}

stop() {

# Stop the bandwidth shaping.
    $TC qdisc del dev $IF root

}

restart() {

# Self-explanatory.
    stop
    sleep 1
    start

}

show() {

# Display status of traffic control status.
    $TC -s qdisc ls dev $IF

}

case "$1" in

    start)

        echo -n "Starting bandwidth shaping: "
        start
        echo "done"
        ;;

    stop)

        echo -n "Stopping bandwidth shaping: "
        stop
        echo "done"
        ;;

    restart)

        echo -n "Restarting bandwidth shaping: "
        restart
        echo "done"
        ;;

    show)

        echo "Bandwidth shaping status for $IF:"
        show
        echo ""
        ;;

    *)

        pwd=$(pwd)
        echo "Usage: tc.bash {start|stop|restart|show}"
        ;;

esac

exit 0

출처> http://www.xelloss.pe.kr/258
http://www.iplocation.net/tools/traffic-control.php
113개(3/6페이지)
운영체제
번호 제목 글쓴이 조회 날짜
73 [리눅스] remi php55 php.ini 수정 푸딩뱃살 1752 2017.04.03 01:08
72 [리눅스] [warn] module php5_module is already loaded, skipping 푸딩뱃살 2090 2017.03.24 02:03
71 [맥] 라이브러리 폴더 보기 푸딩뱃살 1713 2017.03.09 11:34
70 [윈도우] 미러(백업) - robocopy 푸딩뱃살 1716 2016.12.16 10:58
69 [리눅스] yum 패치키 갱신/설치 시 경고 첨부파일 푸딩뱃살 3005 2016.10.04 00:30
68 [리눅스] sendmail aliases(별칭) 설정 푸딩뱃살 2717 2016.09.09 15:37
67 [참고] TCP/UDP 포트 목록 푸딩뱃살 2622 2016.07.21 23:50
66 [리눅스] httpd가 start, restart가 안될 때 푸딩뱃살 3309 2016.07.14 11:49
65 [리눅스] 프로세스 PID 구하기 pgrep, pidof 푸딩뱃살 2629 2016.06.22 13:58
64 [리눅스] svn 설치 / 저장소 생성 / 저장소 삭제 / 설정 첨부파일 푸딩뱃살 25391 2016.06.13 00:30
63 [리눅스] ip 추출 첨부파일 푸딩뱃살 2893 2015.09.29 20:16
62 [윈도우] 윈도우즈 오류 코드 목록 푸딩뱃살 3325 2015.08.31 16:31
61 [리눅스] 콘솔(터미널) 해상도 변경 첨부파일 푸딩뱃살 3971 2015.07.15 01:32
60 [리눅스] grep 사용 푸딩뱃살 709 2015.05.26 09:37
59 [리눅스] Linux / Unix 고급 Bash 스크립팅 가이드 푸딩뱃살 3454 2015.03.08 00:32
58 [리눅스] httpd.conf 설정 (번역) 푸딩뱃살 21379 2015.03.07 23:51
>> [리눅스] tc 명령어를 이용한 트래픽 제한 스크립트 푸딩뱃살 6441 2015.03.07 18:44
56 [리눅스] vsftpd 사용자 계정 설정 푸딩뱃살 3032 2015.01.15 10:20
55 [리눅스] 파티션 정보 확인 fdisk 푸딩뱃살 3754 2015.01.14 01:56
54 [리눅스] 로그 파일 설명 푸딩뱃살 2706 2014.12.23 14:50