日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

rfc5766-turn-server NAT

發(fā)布時(shí)間:2024/8/1 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 rfc5766-turn-server NAT 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

安裝:谷歌推薦的開源穿透服務(wù)器,包含trun和stun服務(wù),主頁:https://code.google.com/p/rfc5766-turn-server/


https://code.google.com/p/rfc5766-turn-server/??


The TURN Server is a VoIP media traffic NAT traversal server and gateway. It can be used as a general-purpose network traffic TURN server/gateway, too.

This implementation also includes some extra features. Supported RFCs:

TURN specs:

RFC 5766 - base TURN specs
RFC 6062 - TCP relaying TURN extension
RFC 6156 - IPv6 extension for TURN
Experimental DTLS support as client protocol.
STUN specs:

RFC 5389 - base "new" STUN specs
RFC 5769 - test vectors for STUN protocol testing
RFC 5780 - NAT behavior discovery support



版本:turnserver-3.2.3.95.tar.gz??系統(tǒng)環(huán)境:centos

下載必要庫
yum install -y make auomake gcc cc gcc-c++ wget
yum install -y openssl-devel libevent libevent-devel mysql-devel mysql-server
wget?https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xvfz libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable && ./configure
make && make install && cd ..

下載turnserver-3.2.3.95.tar.gz并安裝
wget?http://turnserver.open-sys.org/downloads/v3.2.3.95/turnserver-3.2.3.95.tar.gz
tar -xvzf turnserver-3.2.3.95.tar.gz
cd turnserver-3.2.3.95
./configure
make && make install


安裝后,配置turnserver.conf和turnuserdb.conf
啟動(dòng)
turnserver -L <public_ip_address> -c turnserver.conf -o -a -b turnuserdb.conf -f -r <system_domain_name>


可以通過以下指令獲取幫助
turnserver -h


turnserver.conf配置:
# RFC5766-TURN-SERVER configuration file
# RFC5766-TURN-SERVER配置文件
#
# Boolean values note: where boolean value is supposed to be used,
# you can use '0', 'off', 'no', 'false', 'f' as 'false,
# and you can use '1', 'on', 'yes', 'true', 't' as 'true'
# If the value is missed, then it means 'true'.
#
# 布爾值注意: 布爾值應(yīng)該被使用,
# 您可以使用'0', 'off', 'no', 'false', 'f' 相當(dāng)于 'false,
# 還有你可以用'1', 'on', 'yes', 'true', 't' 相當(dāng)于 'true'
# 如果沒有值,相當(dāng)于'true'.
#

# Listener interface device (optional, Linux only).
# NOT RECOMMENDED.
#
# 偵聽器接口設(shè)備(僅可選,Linux)。
# 不推薦。
#
#listening-device=eth0

# TURN listener port for UDP and TCP (Default: 3478).
# Note: actually, TLS & DTLS sessions can connect to the
# "plain" TCP & UDP port(s), too - if allowed by configuration.
#
# TURN為UDP和TCP的偵聽器端口(默認(rèn): 3478)。
# 注:實(shí)際上,TLS和DTLS會(huì)話可以連接到"清晰的"TCP和UDP端口,——如果允許配置。
#
#listening-port=3478
listening-port=3478

# TURN listener port for TLS (Default: 5349).
# Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
# port(s), too - if allowed by configuration. The TURN server
# "automatically" recognizes the type of traffic. Actually, two listening
# endpoints (the "plain" one and the "tls" one) are equivalent in terms of
# functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
# For secure TCP connections, we currently support SSL version 3 and
# TLS version 1.0, 1.1 and 1.2. SSL2 "encapculation mode" is also supported.
# For secure UDP connections, we support DTLS version 1.
#
# TURN為TLS的偵聽器端口(默認(rèn): 5349)。
# 注意:事實(shí)上,"清晰的"TCP和UDP會(huì)話可以連接到TLS和DTLS端口,如果允許配置。
# TURN服務(wù)器"自動(dòng)"識(shí)別傳輸類型。實(shí)際上,兩個(gè)監(jiān)聽終端點(diǎn)("清晰的"端和"TLS"端)是
# 對等的功能;但我們保持兩個(gè)端點(diǎn)來滿足RFC 5766規(guī)范。
# 對于安全的TCP連接,我們目前支持SSL的3個(gè)版本,是TLS 1.0版本,1.1版本和1.2版本。
# SSL2還支持"encapculation模式"。對于安全的UDP連接,我們支持DTLS版本1。
#
#tls-listening-port=5349
tls-listening-port=5349

# Alternative listening port for UDP and TCP listeners;
# default (or zero) value means "listening port plus one".
# This is needed for RFC 5780 support
# (STUN extension specs, NAT behavior discovery). The TURN Server
# supports RFC 5780 only if it is started with more than one
# listening IP address of the same family (IPv4 or IPv6).
# RFC 5780 is supported only by UDP protocol, other protocols
# are listening to that endpoint only for "symmetry".
#
# 選擇UDP和TCP監(jiān)聽器監(jiān)聽端口;
# 默認(rèn)(或者0)是表示監(jiān)聽的端口加1.
# 這是必須的,為了RFC 5780的支持(STUN的擴(kuò)展規(guī)范, NAT后端的發(fā)現(xiàn))。
# TURN服務(wù)器支持RFC 5780只有啟動(dòng)與多個(gè)監(jiān)聽同一族的IP地址(IPv4或IPv6).
# RFC 5780只有UDP協(xié)議,支持其他協(xié)議是監(jiān)聽"對稱"型端口的。
#
#alt-listening-port=0
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???
# Alternative listening port for TLS and DTLS protocols.
# Default (or zero) value means "TLS listening port plus one".
#
# 選擇監(jiān)聽端口TLS和DTLS協(xié)議。
# 默認(rèn)(或者0)是表示TLS監(jiān)聽的端口加1.
#
#alt-tls-listening-port=0
? ??
# Listener IP address of relay server. Multiple listeners can be specified.
# If no IP(s) specified in the config file or in the command line options,
# then all IPv4 and IPv6 system IPs will be used for listening.
#
# 偵聽器中繼服務(wù)器的IP地址。可以指定多個(gè)偵聽器。
# 如果沒有在配置文件或者命令選項(xiàng)中指定監(jiān)聽的IP,
# 那么所有的IPv4和IPv6所有的IP將被監(jiān)聽
#
#listening-ip=172.17.19.101
#listening-ip=10.207.21.238
#listening-ip=2607:f0d0:1002:51::4
listening-ip=<IP>

# Auxiliary STUN/TURN server listening endpoint.
# Aux servers have almost full TURN and STUN functionality.
# The (minor) limitations are:
# 1) Auxiliary servers do not have alternative ports and
# they do not support STUN RFC 5780 functionality (CHANGE REQUEST).
# 2) Auxiliary servers also are never returning ALTERNATIVE-SERVER reply.
# Valid formats are 1.2.3.4:5555 for IPv4 and [1:2::3:4]:5555 for IPv6.
# There may be multiple aux-server options, each will be used for listening
# to client requests.
#
# 輔助STUN/TURN服務(wù)器監(jiān)聽端口。
# 輔助服務(wù)器幾乎有齊TURN和STUN功能
# (一些)局限性:
# 1) 輔助服務(wù)器沒有替代的端口并且他們不支持STUN RFC 5780功能(變更請求)。
# 2) 輔助服務(wù)器也不會(huì)返回ALTERNATIVE-SERVER回復(fù)。
# 有效格式,IPv4的1.2.3.4:5555 和IPv6的[1:2::3:4]:5555。
# 可能會(huì)有多個(gè)aux-server選項(xiàng),每個(gè)將用于監(jiān)聽客戶端請求。
#
#aux-server=172.17.19.110:33478
#aux-server=[2607:f0d0:1002:51::4]:33478

# (recommended for older Linuxes only)
# Automatically balance UDP traffic over auxiliary servers (if configured).
# The load balancing is using the ALTERNATE-SERVER mechanism.
# The TURN client must support 300 ALTERNATE-SERVER response for this
# functionality.
#
# (僅推薦老的Linuxes)
# 在輔助服務(wù)器自動(dòng)均衡UDP流量(如果配置)。
# 使用ALTERNATE-SERVER的負(fù)載均衡機(jī)制。
# TURN客戶端必須支持300個(gè)ALTERNATE-SERVER響應(yīng)。
#
#udp-self-balance

# Relay interface device for relay sockets (optional, Linux only).
# NOT RECOMMENDED.
#
# 終極接口設(shè)備為中繼套接字(可選, 僅Linux).
# 不推薦。
#
#relay-device=eth1

# Relay address (the local IP address that will be used to relay the
# packets to the peer).
# Multiple relay addresses may be used.
# The same IP(s) can be used as both listening IP(s) and relay IP(s).
# If no relay IP(s) specified, then the turnserver will apply the default
# policy: it will decide itself which relay addresses to be used, and it
# will always be using the client socket IP address as the relay IP address
# of the TURN session (if the requested relay address family is the same
# as the family of the client socket).
#
# 中繼地址(本地IP地址將用于傳遞數(shù)據(jù)包的給每個(gè)端)
# 可以使用多個(gè)中繼地址。
# 相同的IP可以用作監(jiān)聽IP和繼電器IP。
# 如果沒有指定中繼IP,那么turnserver將應(yīng)用默認(rèn)策略:它將自行決定使用那個(gè)中繼
# 地址,并且它總是會(huì)使用客戶端套接字的IP地址作為中繼的IP地址在TURN會(huì)話中(如果
# 請求的中繼地址族解決同族的客戶端套接字)。
#
#relay-ip=172.17.19.105
#relay-ip=2607:f0d0:1002:51::5
relay-ip=
<IP>

# For Amazon EC2 users:#
# TURN Server public/private address mapping, if the server is behind NAT.
# In that situation, if a -X is used in form "-X <ip>" then that ip will be reported
# as relay IP address of all allocations. This scenario works only in a simple case
# when one single relay address is be used, and no RFC5780 functionality is required.
# That single relay address must be mapped by NAT to the 'external' IP.
# The "external-ip" value, if not empty, is returned in XOR-RELAYED-ADDRESS field.
# For that 'external' IP, NAT must forward ports directly (relayed port 12345
# must be always mapped to the same 'external' port 12345).
# In more complex case when more than one IP address is involved,
# that option must be used several times, each entry must
# have form "-X <public-ip/private-ip>", to map all involved addresses.
# RFC5780 NAT discovery STUN functionality will work correctly,
# if the addresses are mapped properly, even when the TURN server itself
# is behind A NAT.
# By default, this value is empty, and no address mapping is used.
#
# Amazon EC2用戶:
# TURN服務(wù)器公開/私有的地址映射,假如服務(wù)器是在NAT后端。
# 在這種情況下,如果一個(gè)表單中"-X <ip>"使用一個(gè)-X,然后該ip將被作為中繼ip地址來使用。
# 這種情況只適用于一個(gè)簡單的例子,當(dāng)一個(gè)中繼的地址是被使用,和沒有RFC5780功能是必需的。
# 單個(gè)中繼地址必須通過NAT映射到外部的IP。
# 外部的IP值,假如不為空,通過XOR-RELAYED-ADDRESS字段返回。
# 外部的IP,NAT必須直接轉(zhuǎn)發(fā)端口(轉(zhuǎn)發(fā)端口12345,必須總是映射到相同的外部端口12345)。
# 在更復(fù)雜的情況下,當(dāng)涉及到多個(gè)IP地址,這個(gè)選項(xiàng)必須使用幾次,每個(gè)條目必須形
# 成"-X <public-ip/private-ip>",將所有涉及到的地址。
# RFC5780 NAT發(fā)現(xiàn)STUN功能正常工作,如果正確的地址映射,即使TURN服務(wù)器本身是
# 在一個(gè)NAT后。
# 默認(rèn),該值為空,并且沒有使用地址映射。
#
#external-ip=60.70.80.91
#
#OR:
#
#external-ip=60.70.80.91/172.17.19.101
#external-ip=60.70.80.92/172.17.19.102
external-ip=
<IP>


# Number of relay threads to handle the established connections
# (in addition to authentication thread and the listener thread).
# If set to 0 then application runs relay process in a single thread,
# in the same thread with the listener process (the authentication thread will
# still be a separate thread).
# In the older systems (Linux kernel before 3.9),
# the number of UDP threads is always one thread per network listening endpoint -
# including the auxiliary endpoints - unless 0 (zero) or 1 (one) value is set.
#
# 數(shù)量的中繼線程處理建立連接(除了驗(yàn)證線程和偵聽器線程)。
# 如果設(shè)置為0,那么應(yīng)用程序中繼進(jìn)程在一個(gè)線程中運(yùn)行,在同一
# 個(gè)線程中監(jiān)聽處理(身份驗(yàn)證線程仍然是一個(gè)單獨(dú)的線程)。
# 在舊系統(tǒng)(3.9 Linux內(nèi)核之前),數(shù)量的UDP線程總是一個(gè)線程監(jiān)聽一個(gè)網(wǎng)絡(luò)端點(diǎn),包括輔助端點(diǎn)——除非設(shè)置0或1值。
#
#relay-threads=0
relay-threads=10

# Lower and upper bounds of the UDP relay endpoints:
# (default values are 49152 and 65535)
#
# UDP中繼端點(diǎn)的上下邊界:
# (默認(rèn)是49152至65535)
#
#min-port=49152
#max-port=65535
? ??
# Uncomment to run TURN server in 'normal' 'moderate' verbose mode.
# By default the verbose mode is off.
#
# 取消TURN服務(wù)器運(yùn)行'normal' 'moderate'詳細(xì)模式。
# 默認(rèn)情況下,詳細(xì)模式是關(guān)閉的。
#
#verbose
? ??
# Uncomment to run TURN server in 'extra' verbose mode.
# This mode is very annoying and produces lots of output.
# Not recommended under any normal circumstances.
#
# 取消TURN服務(wù)器運(yùn)行'extra'詳細(xì)模式。
# 這種模式是非常惱人的,產(chǎn)生大量的輸出。
# 在任何正常情況下不建議。
#
#Verbose

# Uncomment to use fingerprints in the TURN messages.
# By default the fingerprints are off.
#
# 取消在TURN消息中使用指紋。
# 默認(rèn)情況下,指紋是關(guān)閉的。
#
#fingerprint

# Uncomment to use long-term credential mechanism.
# By default no credentials mechanism is used (any user allowed).
# This option can be used with either flat file user database or
# PostgreSQL DB or MySQL DB or Redis DB for user keys storage.
#
# 取消使用長期證書機(jī)制。
# 默認(rèn)情況下不使用憑證機(jī)制(允許任何用戶)。
# 這個(gè)選項(xiàng)可能使用用戶數(shù)據(jù)文件或PostgreSQL或MySQL或Redis來存儲(chǔ)用戶密鑰。
#
#lt-cred-mech
lt-cred-mech

# Uncomment to use short-term credential mechanism.
# By default no credentials mechanism is used (any user allowed).
# For short-term credential mechanism you have to use PostgreSQL or
# MySQL or Redis database for user password storage.
#
# 取消使用短期證書機(jī)制。
# 默認(rèn)情況下不使用憑證機(jī)制(允許任何用戶)。
# 短期證書機(jī)制必須使用PostgreSQL或MySQL或Redis數(shù)據(jù)庫來存儲(chǔ)用戶密碼。
#
#st-cred-mech

# This option is opposite to lt-cred-mech or st-cred-mech.
# (TURN Server with no-auth option allows anonymous access).
# If neither option is defined, and no users are defined,
# then no-auth is default. If at least one user is defined,
# in this file or in command line or in usersdb file, then
# lt-cred-mech is default.
#
# 這個(gè)選項(xiàng)是lt-cred-mech或st-cred-mech相反。
# (TURN服務(wù)器no-auth選項(xiàng)允許匿名訪問)。
# 如果沒有選項(xiàng)定義,沒有用戶定義,那么no-auth默認(rèn)。
# 如果至少定義有一個(gè)用戶,在這個(gè)文件中或在命令行或usersdb文件,
# 那么lt-cred-mech默認(rèn)。
#
#no-auth

# TURN REST API flag.
# Flag that sets a special authorization option that is based upon authentication secret.
# This feature can be used with the long-term authentication mechanism, only.
# This feature purpose is to support "TURN Server REST API", see
# "TURN REST API" link in the project's page
#?http://code.google.com/p/rfc5766-turn-server/.
# This option is used with timestamp:
# usercombo -> "timestamp:userid"
# turn user -> usercombo
# turn password -> base64(hmac(secret key, usercombo))
# This allows TURN credentials to be accounted for a specific user id.
# If you don't have a suitable id, the timestamp alone can be used.
# This option is just turning on secret-based authentication.
# The actual value of the secret is defined either by option static-auth-secret,
# or can be found in the turn_secret table in the database (see below).
#
# TURN REST API標(biāo)志。
# 標(biāo)志是設(shè)置一個(gè)特殊的授權(quán)選項(xiàng),是基于身份驗(yàn)證的私密。
# 這個(gè)功能可以用于長期驗(yàn)證機(jī)制。
# 這個(gè)功能的目的是支持"TURN Server REST API",看到"TURN Server REST API"項(xiàng)目的頁面的鏈接
#?http://code.google.com/p/rfc5766-turn-server/。
# 這個(gè)選項(xiàng)是使用時(shí)間戳:
# usercombo -> "timestamp:userid"
# turn user -> usercombo
# turn password -> base64(hmac(secret key, usercombo))
# 這允許TURN憑證占用一個(gè)特定的用戶id。
# 如果你沒有一個(gè)合適的id,可以使用單獨(dú)的時(shí)間戳。
# 這個(gè)選項(xiàng)只是打開基于私密的身份驗(yàn)證。
# 實(shí)際值定義的私密就是通過選擇static-auth-secret,或可以在數(shù)據(jù)庫中找到turn_secret表(見下文)。
#
#use-auth-secret

# 'Static' authentication secret value (a string) for TURN REST API only.
# If not set, then the turn server
# will try to use the 'dynamic' value in turn_secret table
# in user database (if present). The database-stored??value can be changed on-the-fly
# by a separate program, so this is why that other mode is 'dynamic'.
#
# TURN REST API的'Static'身份驗(yàn)證的私密值(字符串)
# 如果沒有設(shè)置,那么turn服務(wù)器將嘗試使用'dynamic'值在用戶數(shù)據(jù)庫的turn_secret表(如果存在)。
# 數(shù)據(jù)庫存儲(chǔ)的值可以隨時(shí)改變,通過單獨(dú)的程序,所以這就是'dynamic'模式。
#
#static-auth-secret? ???

# 'Static' user accounts for long term credentials mechanism, only.
# This option cannot be used with TURN REST API or with short-term credentials
# mechanism.
# 'Static' user accounts are NOT dynamically checked by the turnserver process,
# so that they can NOT be changed while the turnserver is running.
#
# 'Static'用戶長期占憑證機(jī)制。
# 這個(gè)選項(xiàng)不能用于TURN REST API或短期憑證機(jī)制。
# 'Static'用戶帳戶不是turnserver程序動(dòng)態(tài)檢查,所以他們不能改變在turnserver運(yùn)行時(shí)。
#
#user=username1:key1
#user=username2:key2
# OR:
#user=username1:password1
#user=username2:password2
#
# Keys must be generated by turnadmin utility. The key value depends
# on user name, realm, and password:
#
# 鑰匙必須由turnadmin實(shí)用程序生成。鍵值取決于用戶名稱、領(lǐng)域和密碼:
#
# Example:
# 例子,使用以下命令:
#
# $ turnadmin -k -u ninefingers -r?north.gov?-p youhavetoberealistic
#
# Output: 0xbc807ee29df3c9ffa736523fb2c4e8ee
# 輸出是: 0xbc807ee29df3c9ffa736523fb2c4e8ee
#
# ('0x' in the beginning of the key is what differentiates the key from
# password. If it has 0x then it is a key, otherwise it is a password).
# ('0x'開始的關(guān)鍵是區(qū)分從密碼的關(guān)鍵。如果它有0x,那么它是一個(gè)關(guān)鍵,否則這是一個(gè)密碼)。
#
# The corresponding user account entry in the config file will be:
# 相應(yīng)的配置文件中的用戶帳戶條目將:
#
#user=ninefingers:0xbc807ee29df3c9ffa736523fb2c4e8ee
# Or, equivalently, with open clear password (less secure):
#或者是這樣,明文密碼(不安全的):
#user=ninefingers:youhavetoberealistic
#
user=<
yourname:yourpsw>

# 'Dynamic' user accounts database file name.
# Only users for long-term mechanism can be stored in a flat file,
# short-term mechanism will not work with option, the short-term
# mechanism required PostgreSQL or MySQL or Redis database.
# 'Dynamic' long-term user accounts are dynamically checked by the turnserver process,
# so that they can be changed while the turnserver is running.
# Default file name is turnuserdb.conf.
#
# 'Dynamic'用戶帳戶數(shù)據(jù)庫文件名。
# 只有用戶長期機(jī)制可以存儲(chǔ)在一個(gè)文件,短期機(jī)制不會(huì)處理選項(xiàng),短期機(jī)制需要PostgreSQL或MySQL或
# Redis數(shù)據(jù)庫。
# 'Dynamic'的長期用戶帳戶在turnserver程序中動(dòng)態(tài)檢查的,這樣他們可以改變的在turnserver運(yùn)行時(shí)。
# 默認(rèn)文件名是turnuserdb.conf.
#
#userdb=/usr/local/etc/turnuserdb.conf
userdb=/etc/turnuserdb.conf

# PostgreSQL database connection string in the case that we are using PostgreSQL
# as the user database.
# This database can be used for long-term and short-term credential mechanisms
# and it can store the secret value for secret-based timed authentication in TURN RESP API.
# See?http://www.postgresql.org/docs/8.4/static/libpq-connect.html?for 8.x PostgreSQL
# versions connection string format, see
#?http://www.postgresql.org/docs/9.2/static/libpq-connect.html#LIBPQ-CONNSTRING
# for 9.x and newer connection string formats.
#
# PostgreSQL數(shù)據(jù)庫連接字符串,使用PostgreSQL作為用戶數(shù)據(jù)庫。
# 該數(shù)據(jù)庫可用于長期和短期證書機(jī)制,它可以存儲(chǔ)的私密值,為基于私密身份驗(yàn)證的在TURN RESP API中。
# 8.x PostgreSQL版本請參見http://www.postgresql.org/docs/8.4/static/libpq-connect.html的連接字符串
# 格式,9.x和更新的請參閱http://www.postgresql.org/docs/9.2/static/libpq-connect.html?LIBPQ-CONNSTRING
# 的連接字符串格式。
#
#psql-userdb="host=<host> dbname=<database-name> user=<database-user> password=<database-user-password> connect_timeout=30"

# MySQL database connection string in the case that we are using MySQL
# as the user database.
# This database can be used for long-term and short-term credential mechanisms
# and it can store the secret value for secret-based timed authentication in TURN RESP API.
# Use string format as below (space separated parameters, all optional):
#
# MySQL數(shù)據(jù)庫連接字符串,使用MySQL作為用戶數(shù)據(jù)庫。
# 該數(shù)據(jù)庫可用于長期和短期證書機(jī)制,它可以存儲(chǔ)的私密值,為基于私密身份驗(yàn)證的在TURN RESP API中。
# 使用字符串格式如下(空間分離參數(shù),所有可選):
#
#mysql-userdb="host=<host> dbname=<database-name> user=<database-user> password=<database-user-password> port=<port> connect_timeout=<seconds>"

# Redis database connection string in the case that we are using Redis
# as the user database.
# This database can be used for long-term and short-term credential mechanisms
# and it can store the secret value for secret-based timed authentication in TURN RESP API.
# Use string format as below (space separated parameters, all optional):
#
# Redis數(shù)據(jù)庫連接字符串,使用Redis作為用戶數(shù)據(jù)庫。
# 該數(shù)據(jù)庫可用于長期和短期證書機(jī)制,它可以存儲(chǔ)的私密值,為基于私密身份驗(yàn)證的在TURN RESP API中。
# 使用字符串格式如下(空間分離參數(shù),所有可選):
#
#redis-userdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"

# Redis status and statistics database connection string, if used (default - empty, no Redis stats DB used).
# This database keeps allocations status information, and it can be also used for publishing
# and delivering traffic and allocation event notifications.
# The connection string has the same parameters as redis-userdb connection string.
# Use string format as below (space separated parameters, all optional):
#
# Redis狀態(tài)和統(tǒng)計(jì)數(shù)據(jù)庫連接字符串,如果使用(默認(rèn)空,沒有Redis統(tǒng)計(jì)數(shù)據(jù)庫使用)。
# 這個(gè)數(shù)據(jù)庫保持分配狀態(tài)信息,它也可以用于發(fā)布和交付傳輸和分配事件通知。
# 連接字符串有相同的參數(shù)作為redis-userdb連接字符串。
# 使用字符串格式如下(空間分離參數(shù),所有可選):
#
#redis-statsdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"

# Realm for long-term credentials mechanism and for TURN REST API.
#
# TURN REST API的長期憑證機(jī)制范圍。
#
#realm=mycompany.org

# Per-user allocation quota.
# default value is 0 (no quota, unlimited number of sessions per user).
#
# 每個(gè)用戶分配配額。
# 默認(rèn)值為0(沒有配額,每個(gè)用戶無限數(shù)量的會(huì)話)。
#
#user-quota=0

# Total allocation quota.
# default value is 0 (no quota).
#
# 總分配配額。
# 默認(rèn)值為0(無配額)。
#
#total-quota=0

# Max bytes-per-second bandwidth a TURN session is allowed to handle
# (input and output network streams are treated separately). Anything above
# that limit will be dropped or temporary suppressed (within
# the available buffer limits).
#
# TURN會(huì)話允許最大的傳輸占用帶寬(輸入和輸出網(wǎng)絡(luò)流分別處理)。
# 高于限制將被刪除或暫時(shí)抑制(在可用的緩沖區(qū)范圍內(nèi))。
#
#max-bps=0
max-bps=1024

# Uncomment if no UDP client listener is desired.
# By default UDP client listener is always started.
#
# 如果沒有UDP客戶端監(jiān)聽器需要取消。
# 默認(rèn)情況下UDP客戶端監(jiān)聽器總是啟動(dòng)。
#
#no-udp

# Uncomment if no TCP client listener is desired.
# By default TCP client listener is always started.
#
# 如果沒有TCPP客戶端監(jiān)聽器需要取消。
# 默認(rèn)情況下TCPP客戶端監(jiān)聽器總是啟動(dòng)。
#
#no-tcp

# Uncomment if no TLS client listener is desired.
# By default TLS client listener is always started.
#
# 如果沒有TLS客戶端監(jiān)聽器需要取消。
# 默認(rèn)情況下TLS客戶端監(jiān)聽器總是啟動(dòng)。
#
#no-tls

# Uncomment if no DTLS client listener is desired.
# By default DTLS client listener is always started.
#
# 如果沒有DTLS客戶端監(jiān)聽器需要取消。
# 默認(rèn)情況下DTLS客戶端監(jiān)聽器總是啟動(dòng)。
#
#no-dtls

# Uncomment if no UDP relay endpoints are allowed.
# By default UDP relay endpoints are enabled (like in RFC 5766).
#
# 如果不允許UDP中繼端點(diǎn)需要取消。
# 默認(rèn)情況下啟用UDP繼電器端點(diǎn)(如在RFC 5766)。
#
#no-udp-relay

# Uncomment if no TCP relay endpoints are allowed.
# By default TCP relay endpoints are enabled (like in RFC 6062).
#
# 如果不允許TCP中繼端點(diǎn)需要取消。
# 默認(rèn)情況下啟用TCP繼電器端點(diǎn)(如在RFC 5766)。
#
#no-tcp-relay

# Uncomment if extra security is desired,
# with nonce value having limited lifetime (600 secs).
# By default, the nonce value is unique for a session,
# but it has unlimited lifetime. With this option,
# the nonce lifetime is limited to 600 seconds, after that
# the client will get 438 error and will have to re-authenticate itself.
#
# 取消如果需要額外的安全,現(xiàn)時(shí)已有有限的生命周期(600秒)。
# 默認(rèn)情況下,一個(gè)會(huì)話的唯一臨界值,但它一般擁有無限的生命周期。這個(gè)選項(xiàng),臨界值
# 僅限于600秒,之后,客戶端將得到438錯(cuò)誤,將不得不重新認(rèn)證。
#
#stale-nonce

# Certificate file.
# Use an absolute path or path relative to the
# configuration file.
#
# 證書文件。
# 使用絕對路徑或路徑相對于配置文件。
#
#cert=/usr/local/etc/turn_server_cert.pem

# Private key file.
# Use an absolute path or path relative to the
# configuration file.
# Use PEM file format.
#
# 私鑰文件。
# 使用絕對路徑或路徑相對于配置文件。使用PEM文件格式。
#
#pkey=/usr/local/etc/turn_server_pkey.pem

# Private key file password, if it is in encoded format.
# This option has no default value.
#
# 私有密鑰文件密碼,如果是在編碼格式。
# 這個(gè)選項(xiàng)沒有默認(rèn)值。
#
#pkey-pwd=...

# Allowed OpenSSL cipher list for TLS/DTLS connections.
# Default value is "DEFAULT".
#
# 允許OpenSSL的密碼列表為TLS/DTLS連接。
# 默認(rèn)值是"DEFAULT"
#
#cipher-list="DEFAULT"

# CA file in OpenSSL format.
# Forces TURN server to verify the client SSL certificates.
# By default it is not set: there is no default value and the client
# certificate is not checked.
#
# 在OpenSSL格式的CA文件。
# 強(qiáng)制TURN服務(wù)器驗(yàn)證客戶端SSL證書。
# 默認(rèn)情況下它沒有設(shè)置:沒有默認(rèn)值,不檢查的客戶端證書。
#
# Example:
#CA-file=/etc/ssh/id_rsa.cert

# Curve name for EC ciphers, if supported by OpenSSL library (TLS and DTLS).
# The default value is prime256v1.
#
# 曲線名稱的EC密碼,如果由OpenSSL庫支持(TLS和DTLS)。
# 默認(rèn)值是prime256v1。
#
#ec-curve-name=prime256v1

# Use 566 bits predefined DH TLS key. Default size of the key is 1066.
#
# 使用566位預(yù)定義DH TLS鍵。默認(rèn)鍵大小是1066
#
#dh566

# Use 2066 bits predefined DH TLS key. Default size of the key is 1066.
#
# 使用2066位預(yù)定義DH TLS鍵。默認(rèn)鍵大小是1066
#
#dh2066

# Use custom DH TLS key, stored in PEM format in the file.
# Flags --dh566 and --dh2066 are ignored when the DH key is taken from a file.
#
# 使用慣例的DH TLS鍵,使用PEM格式存儲(chǔ)在文件里
# 當(dāng)DH鍵從文件里加載,將忽略標(biāo)志--dh566和--dh2066
#
#dh-file=<DH-PEM-file-name>

# Flag to prevent stdout log messages.
# By default, all log messages are going to both stdout and to
# the configured log file. With this option everything will be
# going to the configured log only (unless the log file itself is stdout).
#
# 標(biāo)志防止輸出日志信息
# 默認(rèn)情況下,所有日志消息將輸出到配置的日志文件。采用這一選項(xiàng)都將只配置日志
# (除非日志文件本身是輸出的)。
#
#no-stdout-log

# Option to set the log file name.
# By default, the turnserver tries to open a log file in
# /var/log, /var/tmp, /tmp and current directories directories
# (which open operation succeeds first that file will be used).
# With this option you can set the definite log file name.
# The special names are "stdout" and "-" - they will force everything
# to the stdout. Also, the "syslog" name will force everything to
# the system log (syslog).
# In the runtime, the logfile can be reset with the SIGHUP signal
# to the turnserver process.
#
# 設(shè)置日志文件
# 默認(rèn)情況下,turnserver嘗試一個(gè)日志文件在/var/log,/var/tmp,/tmp和
# 當(dāng)前目錄(那個(gè)文件先打開成功,文件將被使用)。
# 采用這一選項(xiàng)可以設(shè)置明確的日志文件名。
# 特殊的名字是"stdout"和"-"——他們將強(qiáng)制所有的輸出。同時(shí),"syslog"名稱將強(qiáng)制所有的系統(tǒng)日志(syslog)。
# 在運(yùn)行時(shí),日志文件可以重置通過SIGHUP信號(hào)在turnserver程序中。
#
#log-file=/var/tmp/turn.log

# Option to redirect all log output into system log (syslog).
#
# 選擇重定向所有日志輸出到系統(tǒng)日志(syslog)。
#
#syslog

# This flag means that no log file rollover will be used, and the log file
# name will be constructed as-is, without PID and date appendage.
#
# 這個(gè)標(biāo)志意味著沒有日志文件將使用翻轉(zhuǎn),并按原樣將創(chuàng)建日志文件名稱,沒有PID和日期的附加。
#
#simple-log

# Option to set the "redirection" mode. The value of this option
# will be the address of the alternate server for UDP & TCP service in form of
# <ip>[:<port>]. The server will send this value in the attribute
# ALTERNATE-SERVER, with error 300, on ALLOCATE request, to the client.
# Client will receive only values with the same address family
# as the client network endpoint address family.
# See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description.
# The client must use the obtained value for subsequent TURN communications.
# If more than one --alternate-server options are provided, then the functionality
# can be more accurately described as "load-balancing" than a mere "redirection".
# If the port number is omitted, then the default port
# number 3478 for the UDP/TCP protocols will be used.
# Colon (?characters in IPv6 addresses may conflict with the syntax of
# the option. To alleviate this conflict, literal IPv6 addresses are enclosed
# in square brackets in such resource identifiers, for example:
# [2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 .
# Multiple alternate servers can be set. They will be used in the
# round-robin manner. All servers in the pool are considered of equal weight and
# the load will be distributed equally. For example, if we have 4 alternate servers,
# then each server will receive 25% of ALLOCATE requests. A alternate TURN server
# address can be used more than one time with the alternate-server option, so this
# can emulate "weighting" of the servers.
#
# 選項(xiàng)設(shè)置"redirection"模式。這個(gè)選項(xiàng)的值將備用服務(wù)器的地址UDP和TCP服務(wù)形式的<ip>[:<port>]。
# 服務(wù)器將發(fā)送這個(gè)值屬性ALTERNATE-SERVER,錯(cuò)誤300,在ALLOCATE請求,客戶端。
# 客戶端將只接收和自己相同的地址族的客戶端的值。查看RFC 5389和RFC 5766為ALTERNATE-SERVER的功能描述。
# 客戶端必須使用獲得的值為隨后的TURN通信。如果不止一個(gè)——alternate-server選項(xiàng)提供,那么功能可以更準(zhǔn)確
# 地描述為"load-balancing",而不僅僅是一個(gè)"redirection"。如果端口號(hào)省略,那么為UDP/TCP協(xié)議,使用默認(rèn)端
# 口號(hào)是3478。冒號(hào)(在IPv6地址字符可能與選項(xiàng)的語法沖突。緩解這種沖突,文字IPv6地址包含在方括號(hào)在這種
# 資源標(biāo)識(shí)符,例如[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 。
# 可以設(shè)置多個(gè)備用服務(wù)器。他們將用于循環(huán)的方式。所有服務(wù)器池中被認(rèn)為是平等的重量和載荷將平均分配的原則。
# 例如,如果我們有4個(gè)備用服務(wù)器,每個(gè)服務(wù)器將獲得25%的分配請求。備用TURN服務(wù)器地址可以使用超過一次
# alternate-server選項(xiàng),所以這可以效仿的"weighting"服務(wù)器。
#
# Examples:
#alternate-server=1.2.3.4:5678
#alternate-server=11.22.33.44:56789
#alternate-server=5.6.7.8
#alternate-server=[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478
? ?? ?? ?? ???
# Option to set alternative server for TLS & DTLS services in form of
# <ip>:<port>. If the port number is omitted, then the default port
# number 5349 for the TLS/DTLS protocols will be used. See the previous
# option for the functionality description.
#
# 選項(xiàng)設(shè)置替代服務(wù)器TLS和DTLS服務(wù)形式的<ip>:<port>。
# 如果省略的端口號(hào),那么默認(rèn)端口號(hào)5349將使用TLS/DTLS協(xié)議。看到前面選擇的功能描述。
#
# Examples:
#tls-alternate-server=1.2.3.4:5678
#tls-alternate-server=11.22.33.44:56789
#tls-alternate-server=[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478

# Option to suppress TURN functionality, only STUN requests will be processed.
# Run as STUN server only, all TURN requests will be ignored.
# By default, this option is NOT set.
#
# 選擇抑制TURN功能,只有STUN的請求將被處理。
# 作為STUN服務(wù)器,所有TURN請求將被忽略。
# 默認(rèn)情況下,沒有設(shè)置這個(gè)選項(xiàng)。
#
#stun-only

# Option to suppress STUN functionality, only TURN requests will be processed.
# Run as TURN server only, all STUN requests will be ignored.
# By default, this option is NOT set.
#
# 選擇抑制STUN功能,只有TURN的請求將被處理。
# 作為TURN服務(wù)器,所有STUN請求將被忽略。
# 默認(rèn)情況下,沒有設(shè)置這個(gè)選項(xiàng)。
#
#no-stun

# This is the timestamp/username separator symbol (character) in TURN REST API.
# The default value is ':'.
#
# 這是時(shí)間戳/用戶名分離器符號(hào)(字符)在TURN REST API。
# 默認(rèn)是使用':'
#
# rest-api-separator=:? ??

# Flag that can be used to disallow peers on the loopback addresses (127.x.x.x and ::1).
# This is an extra security measure.
#
# 標(biāo)記用于不接受的端在環(huán)回地址(127.x.x.x 和 ::1)。
# 這是一個(gè)額外的安全措施。
#
#no-loopback-peers

# Flag that can be used to disallow peers on well-known broadcast addresses (224.0.0.0 and above, and FFXX:*).
# This is an extra security measure.
#
# 標(biāo)記用于不接受的端在廣播地址(224.0.0.0和以上的,和FFXX:*)。
# 這是一個(gè)額外的安全措施。
#
#no-multicast-peers

# Option to set the max time, in seconds, allowed for full allocation establishment.
# Default is 60 seconds.
#
# 選項(xiàng)設(shè)置的最大時(shí)間,以秒為單位,允許完整的分配。
# 默認(rèn)60秒
#
#max-allocate-timeout=60

# Option to allow or ban specific ip addresses or ranges of ip addresses.
# If an ip address is specified as both allowed and denied, then the ip address is
# considered to be allowed. This is useful when you wish to ban a range of ip
# addresses, except for a few specific ips within that range.
# This can be used when you do not want users of the turn server to be able to access
# machines reachable by the turn server, but would otherwise be unreachable from the
# internet (e.g. when the turn server is sitting behind a NAT)
#
# 選擇允許或禁止特定的ip地址或ip地址范圍。
# 如果指定一個(gè)ip地址允許和拒絕,那么ip地址被認(rèn)為是允許的。這是有用的,當(dāng)你希望禁止一個(gè)范
# 圍的ip地址,除了一些特定的ip范圍內(nèi)。
# 這可以使用當(dāng)你不希望turn服務(wù)器的用戶能夠訪問機(jī)器通過turn服務(wù)器,但可能是另一方面從互聯(lián)
# 網(wǎng)上不能到達(dá)(例如,當(dāng)turn服務(wù)器是在一個(gè)NAT后)
#
# Examples:
# denied-peer-ip=83.166.64.0-83.166.95.255
# allowed-peer-ip=83.166.68.45

# File name to store the pid of the process.
# Default is /var/run/turnserver.pid (if superuser account is used) or
# /var/tmp/turnserver.pid .
#
# 存儲(chǔ)進(jìn)程pid的文件名。
# 默認(rèn)是/var/run/turnserver.pid(超級(jí)用戶使用)或者是/var/tmp/turnserver.pid
#
#pidfile="/var/run/turnserver.pid"
pidfile="/var/tmp/turnserver.pid"

# Require authentication of the STUN Binding request.
# By default, the clients are allowed anonymous access to the STUN Binding functionality.
#
# 需要STUN綁定請求的身份驗(yàn)證。
# 默認(rèn)情況下,客戶允許匿名訪問STUN綁定功能。
#
#secure-stun

# Require SHA256 digest function to be used for the message integrity.
# By default, the server uses SHA1 (as per TURN standard specs).
# With this option, the server
# always requires the stronger SHA256 function. The client application
# must support SHA256 hash function if this option is used. If the server obtains
# a message from the client with a weaker (SHA1) hash function then the
# server returns error code 426.
#
# 需要SHA256采摘功能用于消息的完整性。
# 默認(rèn)情況下,服務(wù)器使用SHA1(按標(biāo)準(zhǔn)規(guī)格)。
# 采用這一選項(xiàng),服務(wù)器總是需要更強(qiáng)的SHA256功能。客戶端應(yīng)用程序必須支持SHA256散列函數(shù)
# 如果使用這個(gè)選項(xiàng)。如果服務(wù)器獲得消息從客戶端較弱(SHA1)散列函數(shù)那么服務(wù)器返回錯(cuò)誤代碼426。
#
#sha256

# Mobility with ICE (MICE) specs support.
#
# 移動(dòng)的ICE(MICE)的規(guī)范支持。
#
#mobility

# User name to run the process. After the initialization, the turnserver process
# will make an attempt to change the current user ID to that user.
#
# 用戶名運(yùn)行程序。初始化后,turnserver程序?qū)⒃噲D改變當(dāng)前用戶的用戶ID。
#
#proc-user=<user-name>

# Group name to run the process. After the initialization, the turnserver process
# will make an attempt to change the current group ID to that group.
#
# 組名運(yùn)行程序。初始化后,turnserver程序?qū)⒃噲D改變當(dāng)前組的組ID。
#
#proc-group=<group-name>

# Turn OFF the CLI support.
# By default it is always ON.
# See also options cli-ip and cli-port.
#
# 關(guān)掉CLI的支持。
# 默認(rèn)情況下它總是ON。
# 參閱選項(xiàng)cli-ip和cli-port。
#
#no-cli

#Local system IP address to be used for CLI server endpoint. Default value
# is 127.0.0.1.
#
# 本地系統(tǒng)的IP地址將用于CLI服務(wù)器端點(diǎn)。默認(rèn)值是127.0.0.1。
#
#cli-ip=127.0.0.1

# CLI server port. Default is 5766.
#
# CLI服務(wù)器端口。默認(rèn)是5766。
#
#cli-port=5766

# CLI access password. Default is empty (no password).
#
# CLI訪問密碼。默認(rèn)是空的(沒有密碼)。
#
#cli-password=logen

# Server relay. NON-STANDARD AND DANGEROUS OPTION.
# Only for those applications when we want to run
# server applications on the relay endpoints.
# This option eliminates the IP permissions check on
# the packets incoming to the relay endpoints.
#
# 中繼服務(wù)器。NON-STANDARD和DANGEROUS的選擇。
# 只對這些應(yīng)用程序時(shí),我們想在中繼服務(wù)器上運(yùn)行服務(wù)器應(yīng)用程序端點(diǎn)。
# 這個(gè)選項(xiàng)可以消除IP權(quán)限檢查傳遞的數(shù)據(jù)包傳入的端點(diǎn)。
#
#server-relay

# Maximum number of output sessions in ps CLI command.
# This value can be changed on-the-fly in CLI. The default value is 256.
#
# 最大數(shù)量的輸出會(huì)議在ps CLI命令。
# 這個(gè)值可以動(dòng)態(tài)改變在CLI。默認(rèn)值是256。
#
#cli-max-output-sessions

# Set network engine type for the process (for internal purposes).
#
# 設(shè)置網(wǎng)絡(luò)引擎類型(用于內(nèi)部目的)的過程。
#
#ne=[1|2|3]

# Do not allow an SSL/TLS version of protocol
#
# 不允許一個(gè)SSL/TLS版本的協(xié)議
#
#no-sslv2
#no-sslv3
#no-tlsv1
#no-tlsv1_1
#no-tlsv1_2


turnuserdb.conf
#This file can be used as user accounts storage for long-term credentials mechanism.
#這個(gè)文件可以用作長期用戶帳戶存儲(chǔ)憑證機(jī)制。
#
#username1:key1
#username2:key2
# OR:
#username1:password1
#username2:password2
#
# Keys must be generated by turnadmin utility. The key value depends
# on user name, realm, and password:
# 鑰匙必須由turnadmin實(shí)用程序生成。鍵值取決于用戶名稱、領(lǐng)域和密碼:
#
# Example:
# 例子,使用以下命令:
# $ turnadmin -k -u ninefingers -r?north.gov?-p youhavetoberealistic
# Output: 0xbc807ee29df3c9ffa736523fb2c4e8ee
# 輸出是: 0xbc807ee29df3c9ffa736523fb2c4e8ee
#
# ('0x' in the beginning of the key is what differentiates the key from
# password. If it has 0x then it is a key, otherwise it is a password).
# ('0x'開始的關(guān)鍵是區(qū)分從密碼的關(guān)鍵。如果它有0x,那么它是一個(gè)關(guān)鍵,否則這是一個(gè)密碼)。
#
# The corresponding user account entry in the userdb file will be:
# 相應(yīng)的用戶帳號(hào)在userdb文件中是:
#
#ninefingers:0xbc807ee29df3c9ffa736523fb2c4e8ee
# Or, equivalently (less secure):
#或者是這樣(不安全的):
#ninefingers:youhavetoberealistic
#

yourname:yourpsw






同時(shí)筆者也提供了一個(gè)小工具用于檢測你所在網(wǎng)絡(luò)的NAT類型,源文件是有c程序版本和python腳本兩種,可以從 ?https://github.com/node/turn-client?獲取,如果你是windows,那么還可以本文末尾的附件下載預(yù)編譯打包好的.exe文件。 ?

?

?

NAT話題,主要涉及:

- NAT 與 防火墻

- NAT 基本類型 與 原理

- NAT 穿透方式及原理

- 基于NAT穿透的網(wǎng)絡(luò)應(yīng)用

- NAT穿透相關(guān)的工具和開源項(xiàng)目

?

焦點(diǎn)集中在NAT類型以及對應(yīng)的穿透方式,下面分別收錄幾篇文章做進(jìn)一步了解。

?

?

1 網(wǎng)絡(luò) 與 NAT 和 防火墻?

?

?

公網(wǎng)/內(nèi)網(wǎng)IP分配及NAT地址轉(zhuǎn)換協(xié)議 ?

2007-12-04 20:32:48

http://yanshiwen2007.blog.163.com/blog/static/38688705200711483248456/?

?

?

防火墻和NAT

From: 百度文庫

http://wenku.baidu.com/view/1c5ccba10029bd64783e2c94.html

?

?

NAT的四種類型及類型檢測 ??

Posted on 2010-12-16 19:30 bw_0927?

http://www.cnblogs.com/my_life/articles/1908552.html

?

?

多媒體通訊中防火墻和NAT問題的解決

2002-12-26 9:57:00 ?信息源:賽迪網(wǎng) 作者:袁帥

http://it.rising.com.cn/newSite/Channels/Safety/SafeDefend/Defender/200212/26-095709141.htm

?

Linux下的NAT及防火墻的混合應(yīng)用

時(shí)間:2003-12-29 08:00 來源:BitsCN.com?

http://www.bitscn.com/os/linux/200604/7934.html

?

?

2 NAT 穿透

?

NAT穿透

From: wikipedia 維基百科

http://zh.wikipedia.org/wiki/NAT%E7%A9%BF%E8%B6%8A

?

?

NAT的完全分析及其UDP穿透的完全解決方案

2006-07-18

http://zongtongyi.blogbus.com/logs/2857757.html

?

相關(guān)的其他文章:http://zongtongyi.blogbus.com/tag/%E7%A9%BF%E9%80%8FNAT/

?

?

?

NAT穿透

2010-05-09 12:15?

http://blog.csdn.net/feiren127/article/details/5571636

?

?

?

NAT穿透之NAT類型檢測

發(fā)布時(shí)間:2011-01-01 12:07文章來源:黑客防線文章作者:張東輝?

http://www.yunsec.net/a/special/wlgf/wlrq/2011/0101/7820.html

?

?

P2P網(wǎng)絡(luò)“自由”穿越NAT的“秘密”

Posted on 2008-10-12 14:05 chen eric?

http://www.cnblogs.com/lovko/archive/2008/10/12/1309094.html

?

?

?

Symmetric NAT Traversal

http://www.dialogic.com/webhelp/bordernet2020/1.0.0/webhelp/nat_traversal.htm

?

?

3 STUN 和 TURN 協(xié)議?

?

舊版本STUN http://www.ietf.org/rfc/rfc3489.txt

?

新版本STUN http://www.ietf.org/rfc/rfc5389.txt

TURN ? ? ? http://www.ietf.org/rfc/rfc5766.txt

?

?

Symmetric NAT Traversal using STUN

http://tools.ietf.org/id/draft-takeda-symmetric-nat-traversal-00.txt

?

PS: 此協(xié)議是草稿,主要是關(guān)于基于 STUN 來做 Symmetric 類型的NAT穿透;但這不是100%可以成功的,有一定的概率。

?

PS: 新舊STUN協(xié)議及TURN協(xié)議在實(shí)現(xiàn)和使用上的差異?

? ? 久版的STUN主要是基于判斷NAT類型的,而新版本的STUN以及其擴(kuò)展的TURN協(xié)議,摒棄了原來的思路,以獲得一個(gè)可靠可用的通信地址和端口為目標(biāo);

? ? 新版的STUN重在獲得改地址,而TURN則提供了基于已知地址的數(shù)據(jù)傳遞協(xié)議規(guī)范。所以實(shí)踐中,如果STUN告訴我們地址后,可以P2P,則優(yōu)先P2P,否則TURN中轉(zhuǎn)。

? ? 新舊版本的STUN協(xié)議完全不同,協(xié)議設(shè)計(jì)也不同,無法兼容;新版的STUN則和TURN關(guān)系密切,后者是基于前者擴(kuò)展設(shè)計(jì)的,大多數(shù)服務(wù)端也兼容二者。

?

? ??

4 工具與開源項(xiàng)目

?

NAT 類型檢測

?

NAT Check:Check Your Network Address Translator for Compatibility with Peer-to-Peer Protocols

http://midcom-p2p.sourceforge.net/

?

?

?

VC++實(shí)現(xiàn)NAT穿透之NAT類型檢測

http://blog.csdn.net/yincheng01/article/details/4486359

?

?

?

- STUN?

?

stund?

http://sourceforge.net/projects/stun?

?

?

pystun

http://code.google.com/p/pystun/

?

stunclient

http://code.google.com/p/stunclient/source/browse/#svn%2Ftrunk%2Fstun

?

?

- STUN & TURN

?

turnserver

http://turnserver.sourceforge.net/ ?(http://www.turnserver.org/)

?

?

turn-client

https://github.com/node/turn-client

?

?

PS: 下載按時(shí)時(shí)請注意,以上工具和項(xiàng)目中大多使用標(biāo)準(zhǔn)C和python(cpython) .

?

?

?

STUNMAN?

http://www.stunprotocol.org/ ? , ?https://github.com/jselbie/stunserver?

?

Features:

? Compliant with the latest RFCs including 5389, 5769, and 5780. Also includes backwards compatibility for RFC 3489.

?

? Supports both UDP and TCP on both IPv4 and IPv6.

?

? Client test app provided.

?

STUNMAN 使用C++開發(fā),實(shí)現(xiàn)了新版的STUN和TURN協(xié)議,同時(shí)兼容處理舊版的STUN協(xié)議請求。

?

?

Java STUN/TURN 相關(guān):

?

jstun?

http://jstun.javawi.de/

?

stung4j

https://stun4j.dev.java.net/

?

?

5 總結(jié)?

?

- Q: 是否所有NAT都可以穿透??

? A: 不是!簡單說, 只要是cone類型的NAT,則可以穿透,100%地穿透,

? ? ?即 full cone NAT, address restricted cone NAT 和 port restricted cone NAT 都可以穿透;

? ? ?而 symmetric NAT則不能保證100%穿透,也就是說不可靠無法依賴穿透symmetric NAT來通信,必須提供備選方式如代理中轉(zhuǎn)等。

?

- Q: 對于無法穿透的NAT該怎么辦??

? A: 既然有STUN和TURN甚至SOCK5等協(xié)議,那么在確定無法穿透或者不能確定穿透時(shí),選擇服務(wù)器中轉(zhuǎn)是上策。

?

- Q: 實(shí)踐中哪種類型的NAT更多一些?

? A: 有時(shí)候應(yīng)用只需要面對大多數(shù)用戶即可,無需嚴(yán)格考慮所有情況,則需要參考實(shí)踐中的NAT類型比例;

? ? ?這個(gè)數(shù)據(jù)我沒有實(shí)際調(diào)查過,但結(jié)合網(wǎng)絡(luò)上提供的資料,目前大多數(shù)NAT都屬于cone的,不是symmetric的;但典型的sysmmetric仍然存在,比如可能有:

? ? ?- 安全要求較高的內(nèi)部專屬網(wǎng)/局域網(wǎng)

? ? ?- 互聯(lián)網(wǎng)與EGDE網(wǎng)絡(luò)之間,互聯(lián)網(wǎng)與3G網(wǎng)之間

?

?

?

- Q: Symmetric NAT 的穿透狀況到底如何?

? A: 可以穿透,但不是100%成功;那么如何提高成功率呢? http://www.goto.info.waseda.ac.jp/~wei/file/wei-apan-v10.pdf?

? ? ?這篇很早的文章顯示他們的辦法可以達(dá)到99%的NAT穿透率,高于當(dāng)時(shí)SKYPE的46% 。其中的難點(diǎn),主要在于不斷變化的端口映射,導(dǎo)致mapping address無法穩(wěn)定下來用于兩個(gè)peer的通信。

?

?

6 輔助工具

?

在線NAT類型檢測

nattest.net.in.tum.de

?

?

從外部測試本地端口是否可訪問

http://canyouseeme.org/?




總結(jié)

以上是生活随笔為你收集整理的rfc5766-turn-server NAT的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。