AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 902132
Accepted
Tono Nam
Tono Nam
Asked: 2018-03-17 20:17:21 +0800 CST2018-03-17 20:17:21 +0800 CST 2018-03-17 20:17:21 +0800 CST

Asterisk 使用了 sip.conf 中的错误变量

  • 772

我完成了本教程以使用星号进行安全调用。

安全呼叫教程 | 星号项目维基

我在 Ubuntu 版本 16 (debian) 上运行 asterisk 版本 13.19.2,一旦我添加了 TLS 和 SRTP,我就遇到了问题。

如果您想安装星号,请仅阅读此内容!如果您希望安装带有 TLS 和 SRTP 支持的星号以进行安全呼叫,这只是我的说明。实际问题在最底层!


  1. 使用 libsrtp 和 SRTP 安装 asterisk 13.19.2:

{

# (1) make sure everything is up to date again
apt-get update
apt-get upgrade

# (2) Install dependencies that will be needed in order to install asterisk pjproject etc...
apt-get install aptitude -y
aptitude install build-essential -y
aptitude install git -y
aptitude install libssl-dev -y
aptitude install zlib1g-dev -y
aptitude install openssl  -y
aptitude install libxml2-dev -y
aptitude install libncurses5-dev -y
aptitude install uuid-dev -y
aptitude install sqlite3 -y
aptitude install libsqlite3-dev -y
aptitude install pkg-config -y
aptitude install libjansson-dev -y

# (3) make sure everything is up to date again
apt-get update
apt-get upgrade

# (4) Install libsrtp  (library used to encrypt rtp)
cd /root    
wget https://github.com/cisco/libsrtp/archive/v1.6.0.tar.gz
tar -xzf v1.6.0.tar.gz
cd libsrtp-1.6.0

./configure CFLAGS=-fPIC --prefix=/usr
make
make runtest
make install
cd ..

# (5) install pjproject 

git clone https://github.com/asterisk/pjproject pjproject
cd pjproject
 ./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr --with-external-srtp
make dep
make

make install
cd ..


# (6) Install Asterisk  WITH SRTP AND PJPROJECT

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar xvf asterisk-13-current.tar.gz
cd  asterisk-13.19.2
./configure --with-pjproject --with-ssl --with-srtp

make
make install
make samples
make config
  1. 生成密钥(证书)。您也可以从证书颁发机构购买。

    # GENERATE KEYS

    # make a place for our keys mkdir /etc/asterisk/keys

    cd /root/asterisk-13.19.2/contrib/scripts

    ./ast_tls_cert -C my_company.com -O "my_company" -d /etc/asterisk/keys

    # TODO later generate keys for clients (ip phones). This part is explained on first tutorial link and is not relevant to this question

  2. 创建 sip.conf 和 extensions.conf

sip.conf:

[general]
  tcpenable=yes
  udpenable=yes
  udpbindaddr=0.0.0.0
  tcpbindaddr=0.0.0.0

  ; allow tls !
  tlsenable=yes
  tlsbindaddr=0.0.0.0:5868 ; <------------------------ note I am changing the default port 6061 to 5868
  tlscertfile=/etc/asterisk/keys/asterisk.pem ; key generated on step 2
  tlscafile=/etc/asterisk/keys/ca.crt ; certificate generated on step 2
  tlscipher=ALL
  tlsclientmethod=tlsv1
  encryption=yes
  tlsdontverifyserver=yes ; trust ublux more than godaddy!

  videosupport=yes
  nat=force_rport,comedia


; shared configuration used for ip phones
[base-config](!)
  type=peer
  ;type=friend
  disallow=all
  allow=ulaw,h264,vp8
  context=common ;<------------------ context used on extensions.conf
  dtmfmode=auto
  insecure=port,invite
  canreinvite=no
  host=dynamic
  directmedia=no
  registertrying=yes
  qualify=yes; monitof peer in order to know if its connected
  transport=tls ; Only allow secure transport!
  encryption=yes
  icesupport=yes
  dtlsenabled=yes
  dtlsverify=no

sip.conf 上的同行

; peer 1
[101](base-config)
  secret=password123
  setvar=ID=Tono 
  setvar=Foo=test101 

; peer 2
[102](base-config)
  secret=password123
  setvar=ID=Monir
  setvar=Foo=test102 

extensions.conf

[general]
  static=yes
  writeprotect=no

[common]    
  exten => 101,1,NoOp(Calling 101)
  same => n,NoOp(Foo = ${Foo} )
  same => n,Dial(SIP/101)
  same => n,Hangup()

  exten => 102,1,NoOp(Calling 102)
  same => n,NoOp(Foo = ${Foo} )
  same => n,Dial(SIP/102)
  same => n,Hangup()

无论如何,这是一个问题:

执行这些步骤后,我可以拨打电话,接听电话,但发生了一些非常奇怪的事情!Asterisk 使用了不正确的变量。例如,当我从电话呼叫101星号时102,会从 peer 中选择变量102!请注意,这仅在两部电话具有相同 IP 地址时才会发生,因为它们位于 NAT 之后。

这是证明:

ubuntu*CLI> sip show peers
Name/username             Host                                    Dyn 
Forcerport Comedia    ACL Port     Status      Description
101                   170.55.7.131                             D  Yes        Yes            50178    Unmonitored
102                   170.55.7.131                             D  Yes        Yes            50137    Unmonitored
103                   170.55.7.132                             D  Yes        Yes            50212    Unmonitored

对等体 101 和 102 显示相同的 IP 地址,因为它们位于同一路由器后面。换句话说 170.55.7.131 是一个公共 ip。如果他们在哪里拥有不同的公共 IP 地址,则不会发生这种情况。换句话说,由于某些奇怪的原因,这不会在分机 101 和 103 之间发生。

当我从 101 呼叫到 102 时,这是星号日志显示的内容:(正确)

Executing [102@common:1] NoOp("SIP/101-00000095", "Calling 102") in new stack
Executing [102@common:2] NoOp("SIP/101-00000095", "Foo = test101 ") in new stack
Executing [102@common:3] Dial("SIP/101-00000095", "SIP/102") in new stack
Using SIP VIDEO CoS mark 6
 ....

当我从 102 呼叫到 101 时,这是星号日志显示的内容!!:(不正确)

Executing [101@common:1] NoOp("SIP/101-00000097", "Calling 101") in new stack
Executing [101@common:2] NoOp("SIP/101-00000097", "Foo = test101 ") in new stack
Executing [101@common:3] Dial("SIP/101-00000097", "SIP/101") in new stack

为什么 Foo=test101它应该相等test102!通道变量101-00000097包含101它应该是102-00000097因为电话102发起了电话呼叫!

如果我重新启动星号服务并从 102 到 101 进行相同的调用,这就是星号显示的内容:

Executing [101@common:1] NoOp("SIP/102-00000002", "Calling 101") in new stack
Executing [101@common:2] NoOp("SIP/102-00000002", "Foo = test102 ") in new stack
Executing [101@common:3] Dial("SIP/102-00000002", "SIP/101") in new stack

现在它是正确的。是星号将变量映射到IP地址吗??????


解决此问题的临时解决方案:

  1. 出于某种原因,如果我将手机放在具有不同 IP 地址的不同位置,则不会发生这种情况。仅当两部手机在同一网络上并且具有相同的公共 IP 地址时,才会出现此问题。这对我来说毫无意义,因为 NAT 将分配不同的内部端口。

  2. 如果我删除安全性 (tls) 并使用 udp 或 tcp 作为传输方法。这个问题不再发生。

ssl
  • 1 1 个回答
  • 1088 Views

1 个回答

  • Voted
  1. Best Answer
    Tono Nam
    2018-03-17T21:37:26+08:002018-03-17T21:37:26+08:00

    花了一整天的时间终于找到了解决方案。当您从 Internet 复制配置时会发生这种情况!

    无论如何,问题是在我的 sip.conf 上我有

    insecure=port,invite
    

    在 insecure=port 上进行谷歌搜索会产生:

    不安全=端口;允许通过 IP 地址匹配对等体而不匹配端口号

    这就解释了为什么该端口被忽略。所以解决方案是对我的 sip.conf 进行两项更改:

    1. 改为insecure=port,invite_insecure=invite

    2. 改为type=peer_type=friend

    • 3

相关问题

  • 如何使用 Tomcat 5.5 更新 SSL 证书

  • 为 IIS6 自行生成 SSL 证书?

  • plesk 上的域和子域 ssl 访问

  • 如何设置 SSL 邮件服务器?

  • 如何通过 SVN 命令行接受 SSL 证书?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve