#
# ALLNET.ITALIA - Patton FXS Trinity
# Template per generazione di 16 linee analogiche
# a partire da un centralino VoIP con 16 account (emulazione FXS)
# separati per FXS (una porta per account)
#
# IP Patton 		192.168.1.100
# IP GW rete e DNS 	192.168.1.1
# IP Centralino 	192.168.1.50
#
# Configurazione provider VoIP
# Esempio con centralino VoIP (interni 100:115)
#  username 100 password abcdef12345!
#  username 101 password ghilmn54321!
#  username 102 password opqrst98765!
#  username 103 password uxvzad43210!
#  username 104 password qwertyuiodd!
#  username 105 password fghjklpopll!
#  username 106 password uqvazd43210!
#  username 107 password plreinbdieb!
#  username 108 password cbadef12345!
#  username 109 password ihglmn54321!
#  username 110 password qporst98765!
#  username 111 password vxuzad43210!
#  username 112 password ewqrtyuiodd!
#  username 113 password hgfjklpopll!
#  username 114 password vxudaz43210!
#  username 115 password rpleinbdieb!
#

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 192.168.1.1

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

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

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

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

profile tone-set DEFAULT

profile voip DEFAULT
  codec 1 g711alaw64k rx-length 20 tx-length 20
  codec 2 g711ulaw64k rx-length 20 tx-length 20
  codec 3 g729 rx-length 20 tx-length 20
  fax transmission 1 relay t38-udp
  fax transmission 2 bypass g711alaw64k 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

profile ppp DEFAULT

cwmp-client
  shutdown

context cs SWITCH
  national-prefix 0
  international-prefix 00

  routing-table called-e164 RT_DIG_COL_TO_SIP_0
    route .T dest-interface IF_SIP_0
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_1
    route .T dest-interface IF_SIP_1
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_2
    route .T dest-interface IF_SIP_2
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_3
    route .T dest-interface IF_SIP_3

  routing-table called-e164 RT_DIG_COL_TO_SIP_4
    route .T dest-interface IF_SIP_4
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_5
    route .T dest-interface IF_SIP_5
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_6
    route .T dest-interface IF_SIP_6
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_7
    route .T dest-interface IF_SIP_7
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_8
    route .T dest-interface IF_SIP_8
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_9
    route .T dest-interface IF_SIP_9
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_10
    route .T dest-interface IF_SIP_10
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_11
    route .T dest-interface IF_SIP_11

  routing-table called-e164 RT_DIG_COL_TO_SIP_12
    route .T dest-interface IF_SIP_12
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_13
    route .T dest-interface IF_SIP_13
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_14
    route .T dest-interface IF_SIP_14
	
  routing-table called-e164 RT_DIG_COL_TO_SIP_15
    route .T dest-interface IF_SIP_15

  interface fxs IF_FXS_0
    route call dest-table RT_DIG_COL_TO_SIP_0
	
  interface fxs IF_FXS_1
    route call dest-table RT_DIG_COL_TO_SIP_1
	
  interface fxs IF_FXS_2
    route call dest-table RT_DIG_COL_TO_SIP_2
	
  interface fxs IF_FXS_3
    route call dest-table RT_DIG_COL_TO_SIP_3
	
  interface fxs IF_FXS_4
    route call dest-table RT_DIG_COL_TO_SIP_4
	
  interface fxs IF_FXS_5
    route call dest-table RT_DIG_COL_TO_SIP_5
	
  interface fxs IF_FXS_6
    route call dest-table RT_DIG_COL_TO_SIP_6
	
  interface fxs IF_FXS_7
    route call dest-table RT_DIG_COL_TO_SIP_7
	
  interface fxs IF_FXS_8
    route call dest-table RT_DIG_COL_TO_SIP_8
	
  interface fxs IF_FXS_9
    route call dest-table RT_DIG_COL_TO_SIP_9
	
  interface fxs IF_FXS_10
    route call dest-table RT_DIG_COL_TO_SIP_10
	
  interface fxs IF_FXS_11
    route call dest-table RT_DIG_COL_TO_SIP_11
	
  interface fxs IF_FXS_12
    route call dest-table RT_DIG_COL_TO_SIP_12
	
  interface fxs IF_FXS_13
    route call dest-table RT_DIG_COL_TO_SIP_13
	
  interface fxs IF_FXS_14
    route call dest-table RT_DIG_COL_TO_SIP_14
	
  interface fxs IF_FXS_15
    route call dest-table RT_DIG_COL_TO_SIP_15

  interface sip IF_SIP_0
    bind context sip-gateway GW_5060
    route call dest-interface IF_FXS_0
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 100 host-part call
	
  interface sip IF_SIP_1
    bind context sip-gateway GW_5062
    route call dest-interface IF_FXS_1
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 101 host-part call
	
  interface sip IF_SIP_2
    bind context sip-gateway GW_5064
    route call dest-interface IF_FXS_2
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 102 host-part call
	
  interface sip IF_SIP_3
    bind context sip-gateway GW_5066
    route call dest-interface IF_FXS_3
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 103 host-part call

  interface sip IF_SIP_4
    bind context sip-gateway GW_5068
    route call dest-interface IF_FXS_4
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 104 host-part call
	
  interface sip IF_SIP_5
    bind context sip-gateway GW_5070
    route call dest-interface IF_FXS_5
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 105 host-part call
	
  interface sip IF_SIP_6
    bind context sip-gateway GW_5072
    route call dest-interface IF_FXS_6
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 106 host-part call
	
  interface sip IF_SIP_7
    bind context sip-gateway GW_5074
    route call dest-interface IF_FXS_7
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 107 host-part call

  interface sip IF_SIP_8
    bind context sip-gateway GW_5076
    route call dest-interface IF_FXS_8
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 108 host-part call
	
  interface sip IF_SIP_9
    bind context sip-gateway GW_5078
    route call dest-interface IF_FXS_9
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 109 host-part call
	
  interface sip IF_SIP_10
    bind context sip-gateway GW_5080
    route call dest-interface IF_FXS_10
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 110 host-part call
	
  interface sip IF_SIP_11
    bind context sip-gateway GW_5082
    route call dest-interface IF_FXS_11
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 111 host-part call

  interface sip IF_SIP_12
    bind context sip-gateway GW_5084
    route call dest-interface IF_FXS_12
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 112 host-part call
	
  interface sip IF_SIP_13
    bind context sip-gateway GW_5086
    route call dest-interface IF_FXS_13
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 113 host-part call
	
  interface sip IF_SIP_14
    bind context sip-gateway GW_5088
    route call dest-interface IF_FXS_14
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 114 host-part call
	
  interface sip IF_SIP_15
    bind context sip-gateway GW_5090
    route call dest-interface IF_FXS_15
    remote 192.168.1.50
    early-disconnect
    address-translation outgoing-call from-header user-part fix 115 host-part call

context cs SWITCH
  no shutdown

authentication-service AS_SIP
  username 100 password abcdef12345!
  username 101 password ghilmn54321!
  username 102 password opqrst98765!
  username 103 password uxvzad43210!
  username 104 password qwertyuiodd!
  username 105 password fghjklpopll!
  username 106 password uqvazd43210!
  username 107 password plreinbdieb!
  username 108 password cbadef12345!
  username 109 password ihglmn54321!
  username 110 password qporst98765!
  username 111 password vxuzad43210!
  username 112 password ewqrtyuiodd!
  username 113 password hgfjklpopll!
  username 114 password vxudaz43210!
  username 115 password rpleinbdieb!

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

  identity 100

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 100

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_1
  domain 1 192.168.1.50
  match-any-domain

  identity 101

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 101

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 102

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 102

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 103

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 103

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 104

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 104

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 105

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 105

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_6
  domain 1 192.168.1.50
  match-any-domain

  identity 106

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 106

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_7
  domain 1 192.168.1.50
  match-any-domain

  identity 107

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 107

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_8
  domain 1 192.168.1.50
  match-any-domain

  identity 108

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 108

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_9
  domain 1 192.168.1.50
  match-any-domain

  identity 109

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 109

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 110

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 110

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 111

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 111

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 112

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 112

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

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

  identity 113

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 113

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_14
  domain 1 192.168.1.50
  match-any-domain

  identity 114

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 114

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto
	  
location-service LS_SIP_15
  domain 1 192.168.1.50
  match-any-domain

  identity 115

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 115

    registration outbound
      registrar 192.168.1.50
      lifetime 3600
      register auto

context sip-gateway GW_5060
  bind location-service LS_SIP_0

  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_SIP_1

  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
  
context sip-gateway GW_5064
  bind location-service LS_SIP_2

  interface IF_GW_5064
    transport-protocol udp+tcp 5064
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5064
  no shutdown
  
context sip-gateway GW_5066
  bind location-service LS_SIP_3

  interface IF_GW_5066
    transport-protocol udp+tcp 5066
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5066
  no shutdown
  
context sip-gateway GW_5068
  bind location-service LS_SIP_4

  interface IF_GW_5068
    transport-protocol udp+tcp 5068
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5068
  no shutdown

context sip-gateway GW_5070
  bind location-service LS_SIP_5

  interface IF_GW_5070
    transport-protocol udp+tcp 5070
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5070
  no shutdown
  
context sip-gateway GW_5072
  bind location-service LS_SIP_6

  interface IF_GW_5072
    transport-protocol udp+tcp 5072
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5072
  no shutdown
  
context sip-gateway GW_5074
  bind location-service LS_SIP_7

  interface IF_GW_5074
    transport-protocol udp+tcp 5074
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5074
  no shutdown

context sip-gateway GW_5076
  bind location-service LS_SIP_8

  interface IF_GW_5076
    transport-protocol udp+tcp 5076
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5076
  no shutdown
  
context sip-gateway GW_5078
  bind location-service LS_SIP_9

  interface IF_GW_5078
    transport-protocol udp+tcp 5078
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5078
  no shutdown
  
context sip-gateway GW_5080
  bind location-service LS_SIP_10

  interface IF_GW_5080
    transport-protocol udp+tcp 5080
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5080
  no shutdown
  
context sip-gateway GW_5082
  bind location-service LS_SIP_11

  interface IF_GW_5082
    transport-protocol udp+tcp 5082
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5082
  no shutdown
  
context sip-gateway GW_5084
  bind location-service LS_SIP_12

  interface IF_GW_5084
    transport-protocol udp+tcp 5084
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5084
  no shutdown

context sip-gateway GW_5086
  bind location-service LS_SIP_13

  interface IF_GW_5086
    transport-protocol udp+tcp 5086
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5086
  no shutdown
  
context sip-gateway GW_5088
  bind location-service LS_SIP_14

  interface IF_GW_5088
    transport-protocol udp+tcp 5088
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5088
  no shutdown
  
context sip-gateway GW_5090
  bind location-service LS_SIP_15

  interface IF_GW_5090
    transport-protocol udp+tcp 5090
    no transport-protocol tls
    bind ipaddress ROUTER WAN WAN_STATIC

context sip-gateway GW_5090
  no shutdown

sip-survivability
  shutdown

port ethernet 0 0
  bind interface ROUTER WAN
  no shutdown

port fxs 0 0  
  subscriber-number 100
  bind interface SWITCH IF_FXS_0
  no shutdown

port fxs 0 1
  
  subscriber-number 101
  bind interface SWITCH IF_FXS_1
  no shutdown
  
port fxs 0 2
  subscriber-number 102
  bind interface SWITCH IF_FXS_2
  no shutdown

port fxs 0 3
  
  subscriber-number 103
  bind interface SWITCH IF_FXS_3
  no shutdown
  
port fxs 0 4
  
  subscriber-number 104
  bind interface SWITCH IF_FXS_4
  no shutdown
  
port fxs 0 5
  
  subscriber-number 105
  bind interface SWITCH IF_FXS_5
  no shutdown
  
  
port fxs 0 6
  
  subscriber-number 106
  bind interface SWITCH IF_FXS_6
  no shutdown
  
  
port fxs 0 7
  
  subscriber-number 107
  bind interface SWITCH IF_FXS_7
  no shutdown
  
port fxs 0 8  
  subscriber-number 108
  bind interface SWITCH IF_FXS_8
  no shutdown

port fxs 0 9
  
  subscriber-number 109
  bind interface SWITCH IF_FXS_9
  no shutdown
  
port fxs 0 10
  subscriber-number 110
  bind interface SWITCH IF_FXS_10
  no shutdown

port fxs 0 11
  
  subscriber-number 111
  bind interface SWITCH IF_FXS_11
  no shutdown
  
port fxs 0 12
  
  subscriber-number 112
  bind interface SWITCH IF_FXS_12
  no shutdown
  
port fxs 0 13
  
  subscriber-number 113
  bind interface SWITCH IF_FXS_13
  no shutdown
  
  
port fxs 0 14
  
  subscriber-number 114
  bind interface SWITCH IF_FXS_14
  no shutdown
  
  
port fxs 0 15
  
  subscriber-number 115
  bind interface SWITCH IF_FXS_15
  no shutdown