Peel ginger using a spoon, then slice into thin coins. Galangal has a tough skin compared to ginger, so use a knife or vegetable peeler to remove the skin. Slice galangal into thin coins.
Add peppercorns to a medium saucepan set over medium heat. Toast peppercorns, shaking the pan occasionally, until aromatic (about 2 to 3 minutes). Add sugar, water, sliced ginger and galangal, stirring to combine.
Bring mixture to a boil, stirring until sugar is dissolved. Once the mixture is boiling, drop heat to medium-low and simmer for 35 to 40 minutes. You want the mixture to smell very strongly of ginger and galangal.
Take the mixture off of the heat. Let cool completely then strain into a clean jar or other container. Discard solids. Store in the refrigerator for up to 2 months.