#
# ALLNET.ITALIA - Patton Trinity
# Template SBC per la registrazione di un centralino IP o telefono IP verso Patton
# e registrazione di un account VoIP
#
# IP Patton 		192.168.1.100
# Porta Patton		5060 (verso provider) / 5062 (registrazione in ingresso)
# IP GW rete	 	192.168.1.1
# IP DNS			8.8.8.8
# FQDN Provider 	sip.allvoip.it
# Username provider	05112345678
# Password provider abcdefghi!
# Username client	05112345678
# Password client	pattonsbc
#

cli version 4.00
clock local default-offset +01:00
clock local dst-rule DST_ON +01:00 from mar last sunday 02:00 2000 until oct last sunday 03:00 2036

profile aaa DEFAULT
  method 1 local
  method 2 none

console
  use profile aaa DEFAULT

telnet-server
  use profile aaa DEFAULT
  no shutdown

ssh-server
  use profile aaa DEFAULT
  no shutdown

snmp-server
  shutdown

web-server
  protocol http port 80
  no protocol https
  use profile aaa DEFAULT
  no shutdown

ntp
  server 0.patton.pool.ntp.org
  server 1.patton.pool.ntp.org
  server 2.patton.pool.ntp.org
  server 3.patton.pool.ntp.org
  no shutdown

dns-server
  relay dns-client
  shutdown

dns-client
  name-server 8.8.8.8

profile tls DEFAULT
  no authentication incoming
  no authentication outgoing
  private-key pki:private-key/DEFAULT
  own-certificate 1 pki:certificate/DEFAULT

profile voip DEFAULT
  codec 1 g711alaw64k rx-length 20 tx-length 20
  codec 2 g729 rx-length 20 tx-length 20

profile pstn DEFAULT

profile sip DEFAULT

context ip ROUTER

  interface WAN
    ipaddress WAN_STATIC 192.168.1.100/24
    accept default-route routing-table DEFAULT

  routing-table DEFAULT
    route 0.0.0.0/0 gateway 192.168.1.1 metric 0

  bgp
    shutdown

nodems-client
  server auto-discover
  resource any
  shutdown

profile ppp DEFAULT

cwmp-client
  shutdown

  stun
    shutdown

context cs SWITCH
  no shutdown

  interface sip IF_SIP_PROVIDER
    bind context sip-gateway GW_5060
    route call dest-service SVC_SIP_LS
    remote sip.allvoip.it
    early-disconnect
    address-translation outgoing-call from-header user-part fix 05112345678 host-part fix sip.allvoip.it
    address-translation incoming-call called-e164 to-header

  interface sip IF_SIP_CUSTOMER
    bind context sip-gateway GW_5062
    route call dest-interface IF_SIP_0

  service sip-location-service SVC_SIP_LS
    bind location-service LS_CUSTOMER

authentication-service AS_CUSTOMER
  realm 1 smartnode
  username 05112345678 password pattonsbc

authentication-service AS_PROVIDER
  username 05112345678 password abcdefghi!

location-service LS_CUSTOMER
  match-any-domain

  identity 05112345678

    authentication inbound
      authenticate 1 authentication-service AS_CUSTOMER username 05112345678

    registration inbound
      lifetime default 300 min 180 max 640

location-service LS_PROVIDER
  domain 1 sip.allvoip.it

  identity 05112345678

    authentication outbound
      authenticate 1 authentication-service AS_PROVIDER username 05112345678

    registration outbound
      registrar sip.allvoip.it
      lifetime 360
      register auto

context sip-gateway GW_5060
  bind location-service LS_PROVIDER

  interface IF_GW_5060
    transport-protocol udp+tcp 5060
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5060
  no shutdown

context sip-gateway GW_5062
  bind location-service LS_CUSTOMER

  interface IF_GW_5062
    transport-protocol udp+tcp 5062
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5062
  no shutdown

sip-survivability
  shutdown

port ethernet 0 0
  bind interface ROUTER WAN
  no shutdown