How to access the hadoop distributed environment built in the internal network through the external network

in the hadoop environment built by the company, datanode uses the private network ip,. Only the master node has enabled the external network ip,
now the data on the HDFS is remotely obtained through Java, and the datanode address returned by master to the Java program is the private network ip,
Java. What should I do?

Mar.05,2021

modify the local hosts file to add the mapping relationship between the extranet IP and hostname of namenode and datanode (provided there is an extranet IP)

then set it in the code:

Configuration conf = new Configuration();
conf.set("dfs.client.use.datanode.hostname", "true");

after all, local development is just a test, and it is not recommended to change to the hadoop configuration file.

Menu