회원 로그인
|
tc 명령어를 이용한 트래픽 제한 스크립트
tc 명령어를 이용한 트래픽 제한하기
설정은 아래만 수정하면 된다.
IF=eth0 #랜카드명, 주로 eth0 이름을 주소 사용
DNLD=1mbit #다운로드 제한, 단위 MB
UPLD=1mbit #업로드 제한, 단위 MB
IP=xxx.xxx.xxx.xxx #IF에 설정된 호스트 IP
tc.sh로 저장하고, 실행은
출처> http://www.xelloss.pe.kr/258
http://www.iplocation.net/tools/traffic-control.php
설정은 아래만 수정하면 된다.
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
댓글 0개
| 엮인글 0개
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 |