I have two networks ( say 10.20.20.0/24 and 10.20.21.0/24). I use two providers using BGP to provide redundant connections. I have made one of them (Say ISPA ) preferred by setting its local preference to 140 in contrast to ISP B with local preference 120 and longer AS path to influence outbound and inbound paths. What I would like to do is to route 10.20.20.0/24 through ISPA and 10.20.21.0/24 through ISPB. At the same time, if any of the ISP links fail, other should then provide route for both networks. Please look at attached .png image file. Please advise soon.
you should advertise 10.20.20.0/24 and 10.20.20.0/23 to ISPA, 10.20.21.0/24 and 10.20.20.0/23 to ISPB.
In this way you take advantage of most specific route. A /24 prefix is accepted on the internet.
The /23 aggregate is needed for fault tolerance. You need to verify that ISPs are not filtering the /24. You may need an agreement with them.
I assume that these two IP subnets are placeholders for two public ip addresses blocks otherwise NAT is involved and other features would be necessary.
To send traffic to ISPA based on source IP address you need to add PBR policy based routing to the picture. BGP is not enough alone for this.
PBR = policy based routing
Hope to help