### Description
When the nathelper module attempts to send OPTIONS ping messages on a host that has no
default route set, the module errors out with one of two error messages.
```
Nov 1 18:58:01 localhost kam_registrar_1[2896]: ERROR: <core>
[core/udp_server.c:591]: udp_send():
raw_iphdr_udp4_send(12,0x7f5be79587e6,4,...,212.2.172.228:39808,1500): Network is
unreachable(101)
Nov 1 18:58:01 localhost kam_registrar_1[2896]: ERROR: nathelper [nathelper.c:2077]:
nh_timer(): udp_send failed
```
or, when I enable udpping_from_path the error message is as follows
```
Nov 1 18:57:29 localhost kam_registrar_1[2793]: ERROR: nathelper [nathelper.c:2073]:
nh_timer(): send_raw from path failed
Nov 1 18:57:49 localhost kam_registrar_1[2793]: ERROR: nathelper [nathelper.c:2073]:
nh_timer(): send_raw from path failed
```
I am sending nat pings from a registrar behind a proxy. The registrar is on an internal
network, the proxy has an interface on the internal network too.
I am storing the path information in location so that it can be used for the nat pings.
The path information has the local internal address and port of the proxy to send the
keepalive message via.
I have the "force_socket" parameter option set, which, I assume, is the socket
to be used for all nat ping messages. This does not work as expected, I will open a
seperate issue for this particular case.
I would have expected that the messages should be able to send to the proxy weather I have
a default route set or not. NOTE: The default route, in this instance, is not on the same
network that the sip traffic is flowing on.
I guess my expectation here is that if the destination to be sent to is on the same
network as a socket that kamilio is listening on, then we should be able to send. In this
case, the path is going to contain where to send to, but the actual contact of the aor is
totally external.
### Troubleshooting
Module settings are as follows:
registrar
```
modparam("registrar", "method_filtering", 1)
modparam("registrar", "case_sensitive", 1)
modparam("registrar", "append_branches", 0)
modparam("registrar", "use_path", 1)
modparam("registrar", "path_mode", 0)
modparam("registrar", "path_use_received", 1)
modparam("registrar", "path_check_local", 1)
modparam("registrar", "max_contacts", 1)
```
usrloc
```
modparam("usrloc", "db_mode", 0)
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "timer_procs", 4)
modparam("usrloc", "nat_bflag", 6)
```
nathelper
```
modparam("nathelper", "natping_interval", 20)
modparam("nathelper", "natping_processes", 4)
modparam("nathelper", "ping_nated_only", 0)
modparam("nathelper", "sipping_from",
"sip:keepalive@example.com")
modparam("nathelper", "sipping_method", "OPTIONS")
modparam("nathelper", "sipping_bflag", 6)
modparam("nathelper", "force_socket",
"10.7.0.190:5060")
modparam("nathelper", "udpping_from_path", 1)
```
Nathelper force_socket is set to a socket that kamailio is listening on:
```
listen=udp:10.7.0.190:5060
```
An example registered user we are trying to ping:
kamctl ul show
```
{
"jsonrpc": "2.0",
"result": {
"Domain": "location",
"Size": 1024,
"AoRs": [{
"Info": {
"AoR": "example_user(a)example.com".com",
"HashID": -1389656423,
"Contacts": [{
"Contact": {
"Address":
"sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP",
"Expires": 66,
"Q": -1,
"Call-ID": "wE-GD4GzkrtuDAJUBJf1Jg..",
"CSeq": 58,
"User-Agent": "Z 3.15.40006 rv2.8.20",
"Received": "sip:212.2.172.228:39808",
"Path":
"<sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>",
"State": "CS_NEW",
"Flags": 0,
"CFlags": 64,
"Socket": "udp:10.7.0.190:5060",
"Methods": -1,
"Ruid": "uloc-2-59fa1f9d-714-17",
"Instance": "[not set]",
"Reg-Id": 0,
"Last-Keepalive": 1509615136,
"Last-Modified": 1509615136
}
}]
}
}
],
"Stats": {
"Records": 1,
"Max-Slots": 1
}
},
"id": 4836
}
```
#### Reproduction
With the above settings, when I do *not* have a default route set for the host then I
encounter the following error in the logs when attempting to ping:
```
Nov 1 18:57:29 localhost kam_registrar_1[2793]: ERROR: nathelper [nathelper.c:2073]:
nh_timer(): send_raw from path failed
Nov 1 18:57:49 localhost kam_registrar_1[2793]: ERROR: nathelper [nathelper.c:2073]:
nh_timer(): send_raw from path failed
```
If I comment out the "udpping_from_path" module parameter and restart kamailio,
again, with *no* default route set, I get the following error:
```
Nov 1 18:58:01 localhost kam_registrar_1[2896]: ERROR: <core>
[core/udp_server.c:591]: udp_send():
raw_iphdr_udp4_send(12,0x7f5be79587e6,4,...,212.2.172.228:39808,1500): Network is
unreachable(101)
Nov 1 18:58:01 localhost kam_registrar_1[2896]: ERROR: nathelper [nathelper.c:2077]:
nh_timer(): udp_send failed
```
If I add a default route to the system, then the OPTIONS pings are able to flow. See
example traffic in "SIP Traffic" section below.
#### Log Messages
Shown in description and troubleshooting sections
#### SIP Traffic
When a default route is set, successful options messages are sent as below.
```
U 2017/11/02 07:50:54.191717 10.7.0.190:5060 -> 10.7.0.186:5062
OPTIONS sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 10.7.0.190:5060;branch=z9hG4bK5526436.
Route: <sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
To: sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP.
Call-ID: d9993f61-a1fd4752-73cdc76(a)10.7.0.190.
CSeq: 1 OPTIONS.
Content-Length: 0.
.
U 2017/11/02 07:50:54.192896 194.213.29.33:5062 -> 212.2.172.228:39808
OPTIONS sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP
SIP/2.0.
Max-Forwards: 10.
Record-Route:
<sip:194.213.29.33:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Record-Route:
<sip:10.7.0.186:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Via: SIP/2.0/UDP
194.213.29.33:5062;branch=z9hG4bK13ab.9ccb0733fcecc331893d95f2e09485ee.0.
Via: SIP/2.0/UDP 10.7.0.190:5060;rport=5060;branch=z9hG4bK5526436.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
To: sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP.
Call-ID: d9993f61-a1fd4752-73cdc76(a)10.7.0.190.
CSeq: 1 OPTIONS.
Content-Length: 0.
.
U 2017/11/02 07:50:54.248234 212.2.172.228:39808 -> 194.213.29.33:5062
SIP/2.0 200 OK.
Via: SIP/2.0/UDP
194.213.29.33:5062;branch=z9hG4bK13ab.9ccb0733fcecc331893d95f2e09485ee.0.
Via: SIP/2.0/UDP 10.7.0.190:5060;rport=5060;branch=z9hG4bK5526436.
Record-Route:
<sip:194.213.29.33:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Record-Route:
<sip:10.7.0.186:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Contact: <sip:192.168.1.64:39808>.
To:
<sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP>;tag=726ffa30.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
Call-ID: d9993f61-a1fd4752-73cdc76(a)10.7.0.190.
CSeq: 1 OPTIONS.
Accept: application/sdp, application/sdp.
Accept-Language: en.
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE.
Supported: replaces, norefersub, extended-refer, timer, outbound, path,
X-cisco-serviceuri.
User-Agent: Z 3.15.40006 rv2.8.20.
Allow-Events: presence, kpml, talk.
Content-Length: 0.
.
U 2017/11/02 07:50:54.248922 10.7.0.186:5062 -> 10.7.0.190:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 10.7.0.190:5060;rport=5060;branch=z9hG4bK5526436.
Record-Route:
<sip:194.213.29.33:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Record-Route:
<sip:10.7.0.186:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Contact: <sip:192.168.1.64:39808>.
To:
<sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP>;tag=726ffa30.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
Call-ID: d9993f61-a1fd4752-73cdc76(a)10.7.0.190.
CSeq: 1 OPTIONS.
Accept: application/sdp, application/sdp.
Accept-Language: en.
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE.
Supported: replaces, norefersub, extended-refer, timer, outbound, path,
X-cisco-serviceuri.
User-Agent: Z 3.15.40006 rv2.8.20.
Allow-Events: presence, kpml, talk.
Content-Length: 0.
.
```
### Possible Solutions
In this case I added a default route as a work-around, however, I don't think that
this should be the "fix"
### Additional Information
* **Kamailio Version**:
```
version: kamailio 5.0.4 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE,
USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC,
DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER,
USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024,
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled on 10:57:22 Oct 26 2017 with gcc 4.8.5
```
* **Operating System**:
```
CentOS Linux release 7.4.1708 (Core)
Linux localhost 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64
x86_64 x86_64 GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1297