If a consonant sound proceeds a nasal sound, it often(pretty much always) undergoes nasal assimilation. This means that it will take on the sound of whatever nasal sound is made in the same place of articulation(so ㅁ if it is ㅂ/ㅍ ; ㄴ for ㄷ/ㅌ; and ㅇ for ㄱ/ㅋ) so it should be pronounced more like dan'neun.
So the first 이 in the sentence is pretty much the equivalent of "this" and applies to the door. Not sure if that is what you meant. The other 이 is modifying the "닫는 것" so it applies to the action, but they are entirely different 이s. The second 이 is just a subject marker, and in essence meaningless, so it could be dropped without the sentence losing much clarity. The first one could be dropped, but it does carry meaning. It is part of the 이,그,저 set, which is like 여기,거기,저기, or this(by me), that(by you), or that over there(not next to either of us). I hope at least something in all of that was helpful.
I'll preface this by saying that there is a lot going on in this sentence grammar-wise, and breaking it down isn't really duolingo's style. That being said, the 이and 을 by themselves don't really have any meaning. They are just there to mark the subject and object. 을 marks the "door"(문) as the object of "close"(닫다) and 이 marks the gerund "closing"(닫는 것) as the subject. Markers are only used to keep things clear, so native speakers will drop them often if the sub/obj of a sentence is clear (ie "사자 의자 먹었어요" The lion ate the chair)