I did that once, when I was down in my rust removal rabbit hole. I believe that oak ashes were preferred (?). But I just took a few scoops from our fireplace insert, mixed it with a random amount of water, and dropped in a greasy chain.
An oil slick formed at the top, but it did not get the chain as clean as the commercial degreaser. I have no idea what the ph or effective concentration of my solution was: just ‘proof of concept’ experimentation.
I also bought a container of ‘Pure Lye’ from the drain cleaning aisle of a local home center. Hard to dissolve the flakes in room temperature water.
Never tried the old ‘Red Devil’ lye that used to be sold at hardware stores.
I spoke to a chemist at ZEP, via their 1-800 consumer help line, and he convinced me that the commercial degreasers are a better choice for chains, because they contain a variety of cleaners, surfactants, etc., for different types of dirt. And they are reasonably affordable. I still prefer the ones that list ‘sodium hydroxide’ on the label.
Philbert