Egypt has for years been concerned by the strife roiling its neighbours to the west and south.
But it is the outbreak a month ago of the war in Gaza, its neighbour to the east, that is rocking the most populous Arab nation to its foundations.
To Egypt, stability in Libya, its western neighbour, and in Sudan to the south has been an integral part of its national security, with Cairo traditionally keen on keeping its adversaries from gaining a foothold in either country.
For more than a decade now, Egypt has watched with alarm the armed conflict and subsequent chaos in Libya, with which it shares a porous desert border.
The lawlessness in Libya after a Nato-backed uprising in 2011 allowed militants to find a safe haven in its eastern region, which they used as a springboard for deadly attacks in Egypt.
To the south, Sudan has been torn apart by fighting since April between the army and a rival paramilitary.
The conflict there has displaced nearly six million people, of whom more than a million fled the vast and impoverished nation. Nearly 300,000 of those went to Egypt.
Ignited by a deadly rampage in Israel by Hamas on October 7, the Gaza war has already tested Egypt's patience and restraint in a way it had never seen as a result of the conflicts in Libya and Sudan.
Last month, a stray Israeli shell hit a border tower, injuring nine soldiers, two seriously.
Last week, drones launched by Yemen's Iranian-backed Houthi forces hit the Egyptians towns of Taba and Noweiba in the southern region of the Sinai Peninsula, when they fell short of their targets in Israel.
Israel has on four occasions bombarded the Gaza end of the Rafah border crossing between Egypt and the Mediterranean enclave, endangering lives and indicating to Cairo and Hamas, which has ruled Gaza since 2007, that they should not consider sending in relief supplies without its approval.
Egyptian officials say the government is also concerned that an escalation of attacks against Israel by Iran-backed groups other than Hamas, such as Lebanon's Hezbollah and the Houthis, could have serious repercussions for Egypt.
One concern is the Houthis closing the Bab Al Mandeb, the southern entrance of the Red Sea, or the closure by Iran of the strategic Strait of Hormuz at the mouth of the Arabian Gulf.
A disruption to shipping in the Red Sea would mean the suspension of traffic in Egypt's Suez Canal, the vital waterway linking the Red Sea and the Mediterranean and a major source of foreign currency for the dollar-strapped country of 105 million people.
It would also mean a dramatic surge in the price of oil and other essential items on world markets – significantly increasing Egypt's already hefty annual import bill of more than $90 billion.
It is against eventualities such as these that Egypt is making preparations for the worst.
In the four weeks since the Gaza war began, Egypt has placed its armed forces and large police force on high alert. It has also on several occasions put on displays of military might to deter potential foes.
It has asked government institutions to halve their fuel use and is accelerating its procurement abroad of wheat and other essential items to bolster its strategic reserves in case of a major disruption to shipping.
Foremost among Egypt's concerns is that Israel's bombardment of Gaza and the ground offensive now under way will force many of the territory's 2.3 million people to flee for safety across the border into Egypt's sparsely populated Sinai region.
Egypt has warned that it will not allow this to happen for reasons of national security and because this would contribute to the "liquidation" of the Palestinian cause by establishing a homeland for them on land other than their own.
President Abdel Fattah El Sisi, a former general who came to power a decade ago, often prides himself on not having dragged Egypt into risky "adventures" – political parlance for military campaigns outside Egypt.
"Beware of the illusions of power forcing you to take a step and later saying I never carefully weighed my move," Mr El Sisi cautioned troops last month.
"Egypt's armed forces, "with all its capabilities, resources and efficiency has just one objective and that's protecting Egypt and its national security."
This weekend, the armed forces Chief of Staff Gen Osama Askar oversaw war drills with live ammunition by units from the 2nd and 3rd armies, which together comprise a large part of the nation's combat numbers and are normally stationed along the Suez Canal and parts of the Sinai Peninsula.
To maintain calm at home, authorities are now diligently enforcing a de facto ban on street protests in force since 2013, after relaxing it for two weeks at the start of the Gaza war to allow pro-Palestinian rallies across the nation.
Tighter control of the media and heightened scrutiny of social media platforms have also been introduced in a bid to suppress calls for pro-Palestinian street protests or for the government to take punitive action against Israel and its western backers, particularly the US.
To avoid adding to frustration, authorities increased fuel prices at the pump by 14 per cent on Friday, but left unchanged the price of diesel, which is used by public and commercial transport.
A rise in diesel prices invariably leads to price increases across the board, particularly of food.
Unfortunately for Egypt, the Gaza war coincides with a grinding economic crisis that began early in 2022.
The war in Gaza is also affecting tourism, a major source of income, just as the peak winter season is approaching.
The crisis, which the government blames on the coronavirus pandemic and the Russia-Ukraine war, has seen the local currency lose more than 50 per cent of its value since March 2022; a dollar crunch that is suppressing imports and hurting local industries; and record inflation that hit 38 per cent in September.
Adding to the country's already deepening woes, Fitch Ratings last week downgraded Egypt's credit score for the second time this year, citing rising financial risks as progress on fiscal reforms remained slow.
The latest ratings action comes after Fitch revised Egypt's credit score lower in May – the first downgrade it gave the country since 2013 – with a negative outlook, and after S&P Global Ratings also downgraded Egypt last month.