401 is not an error, and in this case, is not a symptom of an error.
Swisscom has refused the call (403) before any attempt to authenticate, so they either do not recognize you as a customer, or there is something about the request they don’t like, e.g.
Request URI in wrong format.
From user in wrong format
From user is not a caller ID authorised for your account.
It is also possible that you have been blacklisted for making too many failed attemtps.
Try setting From Domain to the same value you have in SIP Server, and From User to the same value you have in Username.
If no luck, look at the format of the number sent in the To header on an incoming call, and use that format for the destination number on your outgoing call. For example, 4176387XXXX or +4176387XXXX.
If still no luck, check Swisscom documentation for other header requirements (P-Asserted-Identity, Diversion, etc.)
From Domain and From User worked. I can now make outgoing calls, too. Great!!
A question: What is the idea behind having more outgoing routes? Swisscom does not provide one SIP credential for all numbers; they provide only SIP credentials for each number. Since we have 10 numbers, we have to get 10 SIP credentials for each number.
If you have to have separate credentials, it is because you are using a service that is not intended for use with PABXes. It’s for domestic users and one man businesses, and it is a replacement for a single analogue line, not for a trunk.
(“trunk” means multiple lines to the same place, rather than a connection to the PSTN. SIP doesn’t define the term, because the physical lines are shared by not just telephony, and SIP imposes no limits on the number of simultaneous calls over the one physical line. FreePBX users tend to use it to mean a connection to the PSTN.)
Yes, I can’t understand why Swisscom doesn’t issue a trunk. It’s a service for small businesses. I’m not sure, but I think they offer only trunks for enterprise customers. Other providers even offer trunks for 5 numbers or less.