#
# ALLNET.ITALIA - Patton FXS SmartWare
# Template per generazione di 8 linee analogiche
# a partire da un centralino VoIP con 8 account (emulazione FXS)
# separati per FXS (routing mediante routing-table)
#
# IP Patton 		192.168.1.100
# IP GW rete e DNS 	192.168.1.1
# IP Centralino 	192.168.1.50
#
# Esempio con centralino VoIP (interni 270:277)
#

cli version 3.20
clock local default-offset +01:00
clock local dst-rule DST_ON +02:00 from 02:00 mar last sunday until 03:00 oct last sunday
webserver port 80 language en
sntp-client
sntp-client server primary 0.patton.pool.ntp.org port 123 version 4
sntp-client server secondary 1.patton.pool.ntp.org port 123 version 4
dns-client server 192.168.1.1

system

  ic voice 0
    low-bitrate-codec g729

profile ppp default

profile call-progress-tone defaultAlertingtone
  play 1 1000 425 -12
  pause 2 4000
  play 3 1000 425 -12
  pause 4 4000
  
profile call-progress-tone defaultBusytone
  play 1 500 425 -12
  pause 2 500
  play 3 500 425 -12
  pause 4 500

profile call-progress-tone defaultDialtone
  play 1 200 425 -12
  pause 2 200
  play 3 600 425 -12
  pause 4 1000

profile call-progress-tone defaultReleasetone
  play 1 200 425 -12
  pause 2 200
  play 3 200 425 -12
  pause 4 200

profile tone-set default
  map call-progress-tone dial-tone defaultDialtone
  map call-progress-tone ringback-tone defaultAlertingtone
  map call-progress-tone busy-tone defaultBusytone
  map call-progress-tone congestion-tone defaultReleasetone
  map call-progress-tone release-tone defaultReleasetone

profile voip default
  codec 1 g711alaw64k rx-length 20 tx-length 20
  codec 2 g711ulaw64k rx-length 20 tx-length 20

profile pstn default

profile sip default
  no autonomous-transitioning

profile aaa default
  method 1 local
  method 2 none

context ip router

  interface IF_IP_WAN
    ipaddress 192.168.1.100 255.255.255.0
    tcp adjust-mss rx mtu
    tcp adjust-mss tx mtu

context ip router

	route 0.0.0.0 0.0.0.0 192.168.1.1 0
	
context cs switch
  international-prefix 00
  
  routing-table called-e164 RT_DIG_COL_TO_SIP
    route .T dest-interface IF_SIP_0
  
  routing-table called-e164 SIP_TO_FXS
    route 270 dest-interface IF_FXS_0
	route 271 dest-interface IF_FXS_1
	route 272 dest-interface IF_FXS_2
	route 273 dest-interface IF_FXS_3
	route 274 dest-interface IF_FXS_4
	route 275 dest-interface IF_FXS_5
	route 276 dest-interface IF_FXS_6
	route 277 dest-interface IF_FXS_7

  interface fxs IF_FXS_0
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring
	
  interface fxs IF_FXS_1
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring
	
  interface fxs IF_FXS_2
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring

  interface fxs IF_FXS_3
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring
	
  interface fxs IF_FXS_4
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring
	
  interface fxs IF_FXS_5
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring
	
  interface fxs IF_FXS_6
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring
	
  interface fxs IF_FXS_7
    route call dest-table RT_DIG_COL_TO_SIP
	caller-id-presentation mid-ring

  interface sip IF_SIP_0
    bind context sip-gateway GW_5060
    route call dest-table SIP_TO_FXS
    remote 192.168.1.50 5060
    early-disconnect
    address-translation outgoing-call from-header user-part call host-part fix 192.168.1.50

context cs switch
  no shutdown

authentication-service AS_SIP
  username 270 password Cambiami2021!
  username 271 password Cambiami2021!
  username 272 password Cambiami2021!
  username 273 password Cambiami2021!
  username 274 password Cambiami2021!
  username 275 password Cambiami2021!
  username 276 password Cambiami2021!
  username 277 password Cambiami2021!

location-service LS_SIP
  domain 1 192.168.1.50
  match-any-domain

  identity-group DEFAULT

    registration outbound
      registrar 192.168.1.50 5060
      lifetime 3600
      register auto
	  
  identity 270 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 270
	  
  identity 271 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 271
	  
  identity 272 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 272
	  
  identity 273 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 273
	  
  identity 274 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 274
	  
  identity 275 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 275
	  
  identity 276 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 276
	  
  identity 277 inherits DEFAULT
  
    authentication outbound
      authenticate 1 authentication-service AS_SIP username 277

context sip-gateway GW_5060

  interface IF_GW_5060
    bind interface IF_IP_WAN context router port 5060

context sip-gateway GW_5060
  bind location-service LS_SIP
  no shutdown

port ethernet 0 0
  medium auto
  encapsulation ip
  bind interface IF_IP_WAN router
  no shutdown

port fxs 0 0
  encapsulation cc-fxs
  bind interface IF_FXS_0 switch
  no shutdown

port fxs 0 1
  encapsulation cc-fxs
  bind interface IF_FXS_1 switch
  no shutdown
  
port fxs 0 2
  encapsulation cc-fxs
  bind interface IF_FXS_2 switch
  no shutdown

port fxs 0 3
  encapsulation cc-fxs
  bind interface IF_FXS_3 switch
  no shutdown
  
port fxs 0 4
  encapsulation cc-fxs
  bind interface IF_FXS_4 switch
  no shutdown

port fxs 0 5
  encapsulation cc-fxs
  bind interface IF_FXS_5 switch
  no shutdown

port fxs 0 6
  encapsulation cc-fxs
  bind interface IF_FXS_6 switch
  no shutdown

port fxs 0 7
  encapsulation cc-fxs
  bind interface IF_FXS_7 switch
  no shutdown
