The ability to recognize foreign double-stranded (ds)DNA of pathogenic origin in the intracellular environment is an essential defense mechanism of the human innate immune system. However, the molecular mechanisms underlying distinction between foreign DNA and host genomic material inside the nucleus are not understood. By combining biochemical assays and single-molecule techniques, we show that the nuclear innate immune sensor IFI16 one-dimensionally tracks long stretches of exposed foreign dsDNA to assemble into supramolecular signaling platforms. We also demonstrate that nucleosomes represent barriers that prevent IFI16 from targeting host DNA by directly interfering with these one-dimensional movements. This unique scanning-assisted assembly mechanism allows IFI16 to distinguish friend from foe and assemble into oligomers efficiently and selectively on foreign DNA.