I have an ZTE zxhn h108n router, which needs an 12 V input.
I want to make it work when the electricity goes off.
No, not that UPS. An uninterruptible power supply, also known as a battery backup. This is a box that takes normal AC (e.g., 110-120V in the US) and uses it to charge a battery and power your devices. If power goes out (technically: voltage out of range) then it uses an inverter to power your devices from the battery. All automatically.
You typically want to connect:
Sizes and prices vary, primarily based on the size of the battery which, combined with the size of the load, determines how long it will run when AC is out.
You can connect a battery to the DC side of the NAT router directly and have that be its primary power supply. You would discontinue use of the router's own power block, and use an appropriate off-the-shelf battery charger for that battery type. This battery charger will be perfectly safe if UL listed, and will simply plug into the wall. The AC side will be protected and you'll have access to the safe low voltage side only.
Of course I note this router does not have a phone/line or cable input; that means there is also a cable modem or DSL modem somewhere. If this loses power, the Internet will be inaccessible. Fortunately most such devices also take 12VDC power (check this), and likewise can be run off the same battery.
The market is thick with routers and modems that run on 12VDC; it's easy to buy ones that do.
By the way, the more common standard these days is a combo modem/router that does both the modem part and the NAT router in one unit. The downside to this is less control over features and config. The upside may be less power consumed, which means longer runtime or a smaller battery.
Of course, if the provider-side equipment loses power, you again have no Internet. You need to see how your cable provider responds to loss of power, a lot of them have poletop devices which require power from the nearby electrical wires. I can tell you the phone companies are very, very good at it; with large submarine-sized batteries in the basement of every central office. And generators either onsite or trailered around to switch centers, as needed to top up batteries. Landline phones stay up indefinitely in extended outages.
Your battery system can also top up from solar panels.
It can also power things like iPad or phone chargers.
With an inverter it could also power a refrigerator. However you don't want to leave an inverter running any moment it doesn't have to; they waste a lot of power in conversion losses, even when idling. Powering a natively 12VDC device through an inverter and then wall-wart isn't even stupid; you pay a double conversion loss for no useful gain.
All these factor in to how large the battery has to be, based on the runtime you desire.