There is very little active defense you can do when a portal is under attack. However, when a portal is under attack you will receive email notifications whenever a resonator you deployed is damaged and destroyed. This will allow you to have some heads up when your portals are under attack.
If a portal you control and have the key to is under attack you can remotely connect to that portal through your key and remotely recharge it’s resonators XM supply. This will cause your attacker to have to use more XMP bursters in order to take down the portal. So the attacker will either give up or continue using their XMP bursters and it will become a game of who has the most XM reserves.
Defending is by far one of the most important things you can do in the game actively, it is also one of the hardest things because it’s all about timing as an attacker can take down a portal very fast.