회원 로그인
|
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개(1/6페이지)
번호 | 제목 | 글쓴이 | 조회 | 날짜 |
---|---|---|---|---|
113 | [윈도우] onedrive(sharepoint) 네트워크 드라이브 연결 시 | 푸딩뱃살 | 262 | 2021.12.09 15:25 |
112 | [윈도우] 탐색기에서 svn 오버레이 아이콘이 표시가 안될 때 | 푸딩뱃살 | 248 | 2021.10.20 15:17 |
111 | [리눅스] CentOS 설치 후 오류 메시지 - vmwgfx | 푸딩뱃살 | 849 | 2020.06.27 20:00 |
110 | [윈도우] 윈도우 설치 프로그램 관리 (설치 / 삭제) | 푸딩뱃살 | 732 | 2020.05.16 02:15 |
109 | [윈도우] Visual Studio 2019 Community 설치 시 CPU 사용률 | 푸딩뱃살 | 1229 | 2020.04.30 00:41 |
108 | [맥] Mac에서 Windows 전환 | 푸딩뱃살 | 747 | 2020.03.16 22:40 |
107 | [윈도우] batch 실행 명령창 숨기기 | 푸딩뱃살 | 1207 | 2019.10.07 14:45 |
106 | [윈도우] 네트워크 드라이브 연결 batch | 푸딩뱃살 | 819 | 2019.09.24 10:38 |
105 | [윈도우] utorrentie 제거 | 푸딩뱃살 | 805 | 2019.09.01 01:03 |
104 | [리눅스] vi 대소문자 구분 없이 검색 | 푸딩뱃살 | 1260 | 2019.08.09 00:22 |
103 | [윈도우] 개체 참조가 개체의 인스턴스로 설정되지 않았습니다. | 푸딩뱃살 | 823 | 2019.05.24 22:38 |
102 | [리눅스] CUI 해상도 설정 | 푸딩뱃살 | 1219 | 2019.05.14 00:55 |
101 | [리눅스] 리눅스 디렉토리 구조 | 푸딩뱃살 | 1618 | 2019.05.05 22:09 |
100 | [리눅스] Kernel headers not found for target kernel | 푸딩뱃살 | 1987 | 2019.05.05 12:04 |
99 | [윈도우] 맥북용 윈도우10 부팅 USB 만들기 | 푸딩뱃살 | 1854 | 2019.05.03 18:42 |
98 | [맥] 크롬 비밀번호를 맥 키체인에 넣기 | 푸딩뱃살 | 1007 | 2019.02.12 02:29 |
97 | [윈도우] VirtualBox MacOS 설치 | 푸딩뱃살 | 1358 | 2018.10.23 15:20 |
96 | [윈도우] 윈도우즈 디펜더 검출된 리스트 삭제 | 푸딩뱃살 | 1476 | 2018.10.22 00:36 |
95 | [리눅스] openssl 인증서 생성 | 푸딩뱃살 | 1863 | 2018.09.26 15:24 |
94 | [윈도우] 전원 관리 hiberfil.sys 파일 삭제하기 | 푸딩뱃살 | 1197 | 2018.09.09 13:02 |