how to upnp forward ports via two levels of routers
java, nat, networking, port, upnp
Solution
As far as i know it's not possible with your current setup because you cannot access your router's gateway directly.
There are 2 solutions i can think of.
- Disable your router DHCP server so that he and you will all get your IPs from the second router and than you'll all have the same subnet and you could access each one of the routers.
- Have another PC that is connected to the second router network and make him a server that listens to your commands and this server will execute the UPNP tasks for you. (This will probably need a manual setup of port forwarding first)
Hope i could help.
Problem
i am using the java sbbi library to forward ports. but my router is conected to another router, so the external ip of the first router is a ip that was given by the second router dhcp. is there a way to forward the ports on the second router as well? here is my code: ``` InternetGatewayDevice[] devices=InternetGatewayDevice.getDevices( 1000 ); System.out.println("Found "+devices.length+" Devices"); InternetGatewayDevice dev = devices[ 0 ]; System.out.println(dev); System.out.println( "External IP = " + dev.getExternalIPAddress() ); System.out.println( dev.addPortMapping( "Streamternet", "TCP", null, 1333, "192.168.0.105", 8888, 0 ) ); System.out.println( "waiting for connection" ); HTTPServer.main(null); ```