I ran into this in my first house..
There are a bunch of ways to skin a cat but I ended up getting a PVC flange like
this one and glued a smaller PCV pipe to it to extend down into the pipe. I used a plumbing goop liberally around the bottom of the flange to create a seal with the drain pipe and then anchored the flange to the foundation.
There are a number of
choices on flanges but it kind of looks like this is either a pier and beam house or possibly a 2nd floor. I don't see a good way to attach the flange to the floor/sub-floor but it may be my monitor.