How to get a red line surrounding your wall in clash of clans? I have seen that in many villages. It prevents the enemy from deploying troops in the area?
The red boundary is the safe zone. Every building provides a safe zone of one unit around the building. For example, a 4x4 town hall has a 1 unit safe zone around it which prevents you from placing troops in the 6x6 area.
Safe zones can be combined, and are visible in town edit mode, which is shown below: