Biological ion channels are molecular gatekeepers that control transport across cell membranes. Recreating the functional principle of such systems and extending it beyond physiological ionic cargo is both scientifically exciting and technologically relevant to sensing or drug release. However, fabricating synthetic channels with a predictable structure remains a significant challenge. Here, we use DNA as a building material to create an atomistically determined molecular valve that can control when and which cargo is transported across a bilayer. The valve, which is made from seven concatenated DNA strands, can bind a specific ligand and, in response, undergo a nanomechanical change to open up the membrane-spanning channel. It is also able to distinguish with high selectivity the transport of small organic molecules that differ by the presence of a positively or negatively charged group. The DNA device could be used for controlled drug release and the building of synthetic cell-like or logic ionic networks.