In Internet of Things (IoT) environment, devices often do not have public IPs to communicate with other devices due to addresses getting exhausted. Therefore, Network Address Translation (NAT) is used to translate IPs. Furthermore, NATs often also filter messages just like firewalls, and different types of NATs have different behavior on filtering. This causes difficulties for devices direct communication. However, although there are some NAT traversal methods can be used to traverse NATs, those methods may produce extra overhead or require need to distinguish the types of NATs at first. In this paper, an SDN-based NAT traversal mechanism is proposed to deal with the NAT traversal problem without previous mentioned problems. The centralized management property of software-defined networking (SDN) is utilized to develop this SDN-based NAT traversal mechanism. The functions of NATs are implemented on the controller as an NAT application. The controller controls the translating of addresses and ports, so the controller can own all information to traverse all kinds of NATs. From simulation results, the proposed NAT traversal method can successfully use the same process to traverse all kinds of NATs without producing extra overhead. Furthermore, the NATs are OpenFlow switches in the data plane, so it is flexible to adjust the settings of NATs.