Skip to content

Commit cd0a7e7

Browse files
AmygosCopilot
andcommitted
docs: add NAT local networks section to README
Describe the on-premise behind-NAT scenario introduced in PR #113 (NethServer/dev#7725): how Kamailio avoids hairpin NAT by advertising the private IP in SDP for local clients via port-forwarding rules and dedicated listeners on ports 6060/6061. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 504340f commit cd0a7e7

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,42 @@ Example:
5858

5959
api-cli run module/nethvoice-proxy1/configure-module --data '{"fqdn": "example.com", "addresses": { "address": "192.168.1.1", "public_address": "1.2.3.4" }}'
6060

61+
## NAT scenario: local networks support
62+
63+
In on-premise installations where NethServer 8 is behind NAT
64+
(`public_address` differs from `address`), Kamailio normally advertises
65+
the public IP in SDP for all clients. Local clients (phones on the same
66+
LAN) must then reach NethVoice through the public IP, which requires
67+
hairpin NAT firewall rules — complex to configure and often unfeasible.
68+
69+
By providing the optional `local_networks` parameter the proxy avoids the
70+
need for hairpin NAT by automatically:
71+
72+
1. Adding Kamailio listeners on ports **6060** (SIP/TCP/UDP) and **6061**
73+
(SIPS/TLS) bound to the private IP.
74+
2. Creating firewall port-forwarding rules that redirect traffic arriving
75+
on 5060/5061 **from local network sources** to 6060/6061.
76+
3. Configuring Kamailio to select `PRIVATE_IP:6060` as the outbound socket
77+
for destinations inside local networks, so the **private IP is
78+
advertised in SDP** for local clients — eliminating hairpin NAT.
79+
80+
Remote clients are unaffected and continue to use ports 5060/5061 with
81+
the public IP in SDP.
82+
83+
The network directly attached to `address` is detected automatically from
84+
the routing table. Additional subnets can be declared explicitly via
85+
`local_networks`.
86+
87+
Example:
88+
89+
api-cli run module/nethvoice-proxy1/configure-module --data \
90+
'{"fqdn": "proxy.example.com",
91+
"addresses": {"address": "192.168.1.1", "public_address": "1.2.3.4"},
92+
"local_networks": ["192.168.1.0/24", "10.0.0.0/8"]}'
93+
94+
The `local_networks` field accepts an array of CIDR-notation IPv4 subnets.
95+
Port-forwarding rules are applied and removed automatically when the
96+
configuration is updated or the module is destroyed.
6197

6298
## Debug
6399

0 commit comments

Comments
 (0)