Page 1 of 2

Obtain external internet IP address

Posted: Wed Oct 23, 2013 9:36 pm
by Lachlanp
How can i get the Netburener to determine its www internet IP address so that i can access it from the internet?

Is there anyway to fix this so it is always at the same address when it fires up?
I have configured the Netburner with a fixed LAN based IP address.

What port forwarding addresses need to be set in the ADSL modem/router?
80 for HTTP (Is this automatic or do i need to set this explicittly?)
20034 for internet based software updates?
??? for FTP access?
Any others i need to be aware of?

Is there any example programs in the netburner library?

Thanks
Lachlan

Re: Obtain external internet IP address

Posted: Thu Oct 24, 2013 4:07 am
by Ridgeglider
Sure: Just use the NB IPsetup tool to set a static address rather than the default DHCP scheme, one that's appropriately addressable on you network. Sounds like you may have already done this, but if so, it should remain the same once configured. Usually, folks don't need to change addresses once the NB is up an running, but it can be done: See the DHCP example C:\nburn\examples\StandardStack\DHCP\ChangeIP

Re: Obtain external internet IP address

Posted: Thu Oct 24, 2013 6:40 am
by Lachlanp
Thanks, but the address I have set up is LAN address, I.e 192.168.1.90. The question is how I relTe this to a network address.

On my PC the local address is 192.168.1.17, but if I use the network softwRe whatsMyIp, it gives me the address 82.167.124.xxx. The address 192.168.1.90 is not addressable from beyond the LAN.

How do I do the same thing for the netburner. Albo, if my service provider assigns the external IP address, how do I ensure they assign the same external IP address

Regards
Lachlan

Re: Obtain external internet IP address

Posted: Thu Oct 24, 2013 7:40 am
by Chris Ruff
I think you are questioning how to talk to NB from the internet.

If so:

1. set static IP in NB (e.g. 192.168.0.22)
2. in your internet-facing router go to port forwarding or game screen and specify that any traffic going to a port, say 4343 is routed to the NB 192.168.0.22
3. from the internet you open a socket to the NB by using the internet IP 82.167.124.xxx at port 4343 and you are connecting to NB module

Problems:

1. if your internet IP changes (like most do) occasionally this scheme breaks.
2. if you buy a static IP from ISP that fixes (1), but at some point ISP may block 4343 (because they don't like incoming traffic) and yer broken again.
3. if you buy a dedicated IP with commercial inbound access contracted in, this fixes 1 and 2 but money leaves your bank account every month in larger amounts than having a residential ISP account

In residential ISP situations, the NB should connect out to a server. That will never break.
But then you have to pay for the server support....

Chris

Re: Obtain external internet IP address

Posted: Thu Oct 24, 2013 2:17 pm
by Lachlanp
Thank you, that explains some things very well.

However, I still don't know how I obtain the external Internet address that connects the outside world to the netburner? On my PC I can use the program 'WhTsMyIp' but i don't know how to do this for the Netburner?

Do you have any idea how I can get that. If I can display this on an LCD screen then I will know if it changes after a reboot.

Regards
Lachlan

Re: Obtain external internet IP address

Posted: Thu Oct 24, 2013 3:01 pm
by rnixon
One way would be to do a wireshark capture of the transaction from your PC. You could then write some code on the netburner to simulate a web browser request to WhatsMyIp and get the address the same way. A HTTP GET request is just a protocol sent over a tcp connection.

Re: Obtain external internet IP address

Posted: Thu Oct 24, 2013 3:11 pm
by Chris Ruff
So you want to have a netburner-style "whats my ip"?

The only way I know you could do that reliably would be to have a server app out on the internet that you would open a socket to and it would send you back the 'from' IP in a format you could understand- NOT a web page full of adverts but a tiny burst of, say, only your IP address.

I am sure that something like that is out there, but I personally don't know what it would be

It is kind of a PING, but not a PING at all

......... However ....

If you have a static IP at your internet-facing interface- then all of this is unnecessary. I had a static DSL-based IP address for 10 years for the usual $45- USD

Chris


Chris

Re: Obtain external internet IP address

Posted: Sun Oct 27, 2013 8:12 am
by Lachlanp
Is it possible to access the "whatsmyip" server to get the ip address.

if I use the command
GetHostByName("www.whatsmyip.org", &ip_add, 0, 100); It gives me the address as 208.64.38.55 which is correct.

if I then connect using
fd = connect(ip_add, 0, 80, 100); this gives me a valid fd

I should then send a GET request using
const char send_msg[] = {"GET index.html HTTP/1.0\r\n"};
write( fd, send_msg, strlen(send_msg);

Then I should be able to get the response
n = ReadWithTimeout(fd, rcv_msg, MAX_BUF_SIZE, 100);

However, when I do this I don't get any bytes returned and n is 0

Is this logic OK and if so, why does the Netburner receive no data.
I haven't as yet set any port forwarding on the ADSL router, but as a client accessing an external server I would think this is not a problem in this case.

Any ides ?

Thanks
Lachlan

Re: Obtain external internet IP address

Posted: Sun Oct 27, 2013 8:27 am
by rnixon
What your doing was my original suggestion. You need to know the exact format of the GET request, and also confirm it is just HTML. Use wireshark to capture the outgoing packet from your PC so you know what the format is. Then see if you can do the same with the netburner unit. You won't need all the stuff the browser sends, there there be some minimal amount the server is looking for. Use wireshark to look at what your code is sending as well.

Re: Obtain external internet IP address

Posted: Sun Oct 27, 2013 9:40 am
by Lachlanp
Thanks. I have it working now.

However, it sends me the message:
"Please don't use this site to power an IP bot or other IP networking tools, port scanners, tracer, ....."

Is there another site I can use that you would know of ?

Thanks
Lachlan