Asterisk not registering to SIP provider

I have clean Debian VPS that I have installed Asterisk on.
I have a SIP account and number with a VoIP provider. I’m trying to make my asterisk register to that SIP account. However, it always times out. I’m fairly new to asterisk but I think the sip.conf is correct.

I turned on debugging and this is what I get every time

---
Retransmitting #7 (no NAT) to 80.244.65.70:5060:
REGISTER sip:sip-gw6.t3.se SIP/2.0
Via: SIP/2.0/UDP 11.MY.VPS.IP:5060;branch=z9hG4bK72be2ee7
Max-Forwards: 70
From: <sip:USERNAME@sip-gw6.t3.se>;tag=as5ace2218
To: <sip:USERNAME@sip-gw6.t3.se>
Call-ID: 4d010f6f689d1a1420696c025f07cb18@127.0.1.1
CSeq: 103 REGISTER
User-Agent: Asterisk PBX 11.13.1~dfsg-2+b1
Expires: 120
Contact: <sip:provider@11.MY.VPS.IP:5060>
Content-Length: 0


---
REGISTER 10 headers, 0 lines
Reliably Transmitting (no NAT) to 80.244.65.70:5060:
REGISTER sip:sip-gw6.t3.se SIP/2.0
Via: SIP/2.0/UDP 11.MY.VPS.IP:5060;branch=z9hG4bK71b213aa
Max-Forwards: 70
From: <sip:USERNAME@sip-gw6.t3.se>;tag=as5ace2218
To: <sip:USERNAME@sip-gw6.t3.se>
Call-ID: 4d010f6f689d1a1420696c025f07cb18@127.0.1.1
CSeq: 104 REGISTER
User-Agent: Asterisk PBX 11.13.1~dfsg-2+b1
Expires: 120
Contact: <sip:provider@11.MY.VPS.IP:5060>
Content-Length: 0


---
[Jul 27 05:51:32] NOTICE[588]: chan_sip.c:15071 sip_reg_timeout:    -- Registration for 'USERNAME@sip-gw6.t3.se' timed out, trying again (Attempt #3)
Really destroying SIP dialog '4d010f6f689d1a1420696c025f07cb18@127.0.1.1' Method: REGISTER
Retransmitting #1 (no NAT) to 80.244.65.70:5060:
REGISTER sip:sip-gw6.t3.se SIP/2.0
Via: SIP/2.0/UDP 11.MY.VPS.IP:5060;branch=z9hG4bK71b213aa
Max-Forwards: 70
From: <sip:USERNAME@sip-gw6.t3.se>;tag=as5ace2218
To: <sip:USERNAME@sip-gw6.t3.se>
Call-ID: 4d010f6f689d1a1420696c025f07cb18@127.0.1.1
CSeq: 104 REGISTER
User-Agent: Asterisk PBX 11.13.1~dfsg-2+b1
Expires: 120
Contact: <sip:provider@11.MY.VPS.IP:5060>
Content-Length: 0

This is my sip.conf

[general]
port=5060
bindaddr=0.0.0.0
qualify=no
disable=all
allow=alaw
allow=ulaw
dtmfmode=rfc2833
srvlookup=yes
register => USERNAME:PASSWORD@sip-gw6.t3.se/provider

[provider]
type=peer
insecure=port,invite
nat=no
canreinvite=no
authuser=USERNAME
defaultuser=USERNAME
fromuser=USERNAME
fromdomain=sip-gw6.t3.se
secret=PASSWORD
host=sip-gw6.t3.se
dtmfmodf=rfc2833
context=provider-in ;extensions.conf context for inbound calls
disallow=all
allow=ulaw
allow=alaw

I can register fine using Softphone on my PC. Any help would be greatly appreciated. I’ve followed x amount of guides but asterisk never succeeds to register and I’m not sure what could be going wrong. It’s timing out but maybe something in the sip.conf isn’t configured correctly. I have not installed a firewall on this VPS.

First of all, it looks like a network-level issue, not a problem with Asterisk.
Hi,

  1. Do you mean that you can register on the provider’s side from your PC? Or you can register on the Asterisk itself from your PC?

  2. Does your VPS have a public IP address? Otherwise you should configure NAT in Asterisk.

  3. Is the incoming SIP traffic allowed to your server by iptables?
    iptables -nL -v

  4. Check whether any incoming SIP packets arrive:
    tcpdump -i [interface name] -n -w [filename.pcap]
    Then download your filename.pcap and open it with Wireshark on a PC.

Hey!

  1. I mean that I can successfully register to the provider on my own PC using Softphone so there’s no issue with SIP account itself.

  2. Yes, it only has a public IP and the local loopback

  3. This is what the output when I run iptables -nL -v

    Chain INPUT (policy DROP 0 packets, 0 bytes)
    pkts bytes target prot opt in out source destination
    0 0 ACCEPT all – lo * 0.0.0.0/0 0.0.0.0/0
    375 33441 ACCEPT all – eth0 * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
    9 961 DROP tcp – * * 0.0.0.0/0 0.0.0.0/0 tcp flags:!0x17/0x02 state NEW
    0 0 DROP all -f * * 0.0.0.0/0 0.0.0.0/0
    0 0 DROP tcp – * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x3F/0x3F
    0 0 DROP tcp – * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x3F/0x00
    7 412 ACCEPT tcp – eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 state NEW
    1 786 ACCEPT udp – eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:5060 udp
    0 0 ACCEPT tcp – eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:5060 tcp
    0 0 ACCEPT udp – eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpts:10000:20000 udp
    0 0 ACCEPT icmp – * * 0.0.0.0/0 0.0.0.0/0 icmptype 8 state NEW
    11 607 REJECT all – * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

    Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
    pkts bytes target prot opt in out source destination

    Chain OUTPUT (policy ACCEPT 571 packets, 111K bytes)
    pkts bytes target prot opt in out source destination

  4. I will check this when I get home, but the sip.conf file looks fine?
    When I run sip show registry I get this,

    Host dnsmgr Username Refresh State Reg.Time
    sip-gw6.t3.se:5060 N USERNAME 120 Request Sent
    1 SIP registrations.

Also, when I run sip reload I get this,

NOTICE[1726]: chan_sip.c:15109 transmit_register: Strange, trying to register USERNAME@sip-gw6.t3.se when registration already pending

I also just ran asterisk -c and then I get a bunch of these,

NOTICE[1775][C-00000000]: chan_sip.c:25628 handle_request_invite: Call from '' (89.163.146.150:5078) to extension '810972599158234' rejected because extension not found in context 'default'.
NOTICE[1775]: chan_sip.c:28066 handle_request_register: Registration from '"102" <sip:102@11.MY.VPS.IP>' failed for '146.0.32.173:5074' - Wrong password

I have no idea what those IP-addresses are.
I also ran tcptrack on port 5060 but it never showed anything.

I ran the tcpdump on eth0 and this is what I got

0.482752	11.MY.VPS.IP	80.244.65.70	SIP	436	Request: REGISTER sip:sip-gw6.t3.se (1 binding) |
4.482629	11.MY.VPS.IP	80.244.65.70	SIP	436	Request: REGISTER sip:sip-gw6.t3.se (1 binding) |
8.482615	11.MY.VPS.IP	80.244.65.70	SIP	436	Request: REGISTER sip:sip-gw6.t3.se (1 binding) |
12.481605	11.MY.VPS.IP	80.244.65.70	SIP	436	Request: REGISTER sip:sip-gw6.t3.se (1 binding) |
16.482822	11.MY.VPS.IP	80.244.65.70	SIP	436	Request: REGISTER sip:sip-gw6.t3.se (1 binding) |
16.981391	11.MY.VPS.IP	8.8.8.8			DNS	83	Standard query 0x719e SRV _sip._udp.sip-gw6.t3.se
16.986576	8.8.8.8			11.MY.VPS.IP	DNS	132	Standard query response 0x719e No such name SRV _sip._udp.sip-gw6.t3.se SOA ns1.t3.se
16.986691	11.MY.VPS.IP	8.8.8.8			DNS	83	Standard query 0x45b3 SRV _sip._udp.sip-gw6.t3.se
16.990941	8.8.8.8			11.MY.VPS.IP	DNS	132	Standard query response 0x45b3 No such name SRV _sip._udp.sip-gw6.t3.se SOA ns1.t3.se
16.991145	11.MY.VPS.IP	8.8.8.8			DNS	73	Standard query 0x01e5 A sip-gw6.t3.se
16.995072	8.8.8.8			11.MY.VPS.IP	DNS	89	Standard query response 0x01e5 A sip-gw6.t3.se A 80.244.65.70
16.995265	11.MY.VPS.IP	80.244.65.70	SIP	436	Request: REGISTER sip:sip-gw6.t3.se (1 binding) |

Either your network is failing to get the request to the ITSP, or the ITSP is unable to root responses back to 11.MY.VPS.IP You will need to ask the ITSP whether they are receiving your requests.

I could successfully connect to SIP.US so maybe my ITSP just doesn’t allow connections to be made from abroad. It’s a Swedish company so maybe they’re blocking connections being made from outside of Sweden.

So, I had to look up my theory from above and it turns out it should work just fine connecting from a different country. So I moved my VPS to a datacenter in NYC instead of Amsterdam and it worked just fine! So just out of curiosity I transferred it to a London datacenter and it would not register. So either some countries are blocked or some specific IP ranges are blocked and I got unlucky twice.

Either way, moved it back to NYC and it works. Just a bummer I can’t keep it closer to Sweden (latency…).

Anyways, thanks for all the help! :smiley: