# Environment
Kamailio-433 installed behind nat (Amazon EC2 or Google Compute Engine) using config
```cfg listen=PRIVATE_IP:PORT advertise PUBLIC_IP:PORT ```
# What I wanted to do
In table `location`, the column `socket` will be stored in the form of "PROTO:**PRIVATE_IP**:PORT" while for some reasons I would like it to be stored as "PROTO:**PUBLIC_IP**:PORT"
Through the `registrar` document there is the [xavp_cfg](http://wwwkamailioorg/docs/modules/43x/modules/registrarhtml#registrarpxavp_...) parameter that can be used in conjunction with the attribute "socket" to specify the socket string From my understanding this might be the solution to my requirement
# Problem
The column `location``socket` wasn't changed when setting the custom socket string via `xavp_cfg`
After looking into the source code, firstly, a potential bug (correct me if I'm wrong) that it would reset the `sock_flag` to -1 (no flags) even if `reg_xavp_cfg` and `sock_flag` is set A pull request #470 has been opened for this
Secondly, if we pass the above problem, in `savec` it did grab the socket string from xavp_cfg and in function `grep_sock_info()` the socket string was checked with all the address we listen on, including the advertised public address via `socket_info->useinfo` But the returned socket structure still contains the private address info
# Conclusion so far
So, I wasn't sure if using the parameter `xavp_cfg` for setting socket string and stores it in location table make sense or not If yes, can you please giving me some hints about the potential way to extend this?
Cheers, Ian
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/471
The purpose of the value in the database table 'location' is for internal usage of Kamailio. Why would you need to be the advertised address? Is for external purposes?
That value is used by kamailio when doing the lookup(location) to find the appropriate socket. If the socket is not found, then the field is ignored.
If you just need the socket for some external purpose, better save it as a location attribute, it will be stored in location_attrs table.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/471#issuecomment-180520260
Closed #471.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/471#event-547785018
If the location_attrs table, as described in the above comment, is not giving you what is wanted, then re-open, or perhaps it is better to start a discussion on sr-users@lists.sip-router.org mailing list.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/471#issuecomment-183067394
Sorry for late reply since it was lunar new year in Taiwan.
The reason we need the the advertised address is we have several kamailio servers hosted in different cloud hosting service and we will manually get the `socket` information (IP address in our case) from `location` table. Therefore if the address stored in `socket` column are internal IPs then it would fail when our other relay servers try to communicate with those internal IPs. (Since other servers may be located in different datacentre).
But I think it's our design problem, your suggestion is great and we will be sorting out according to it.
Thanks!
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/471#issuecomment-183632338