Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
131 user(s) are online (126 user(s) are browsing Forums)

Members: 0
Guests: 131

more...

Support us!

Headlines

 
  Register To Post  

IP address in CLI
Just popping in
Just popping in


See User information
Hi

Which command do i use to get the external and internal IP address of the current system.

For example my internal IP address may be 192.168.0.3

external could be 8.159.79.108

How can i get the internal and external IP addresses returned in the CLI.

I imagine doing in in C would be a nightmare :(.


Go to top
Re: IP address in CLI
Just can't stay away
Just can't stay away


See User information
@angelheart
Shownetstatus gives the internal IP address

Go to top
Re: IP address in CLI
Quite a regular
Quite a regular


See User information
Routers probably give this information (external IP) only after a login.

Go to top
Re: IP address in CLI
Just can't stay away
Just can't stay away


See User information
@angelheart

Use SysMon (os4depot), shows you all "typicall" system data, network data, including external IP

Go to top
Re: IP address in CLI
Home away from home
Home away from home


See User information
@angelheart
Internal like JosDuchit say:

Quote:

6/10.RAM Disk:> shownetstatus | grep Local
Local host address = 192.168.1.6 (on interface 'interface')


External : use wget or curl and access to some page which will return back your external ip, like this:

Quote:

6/2.RAM Disk:> wget http://wtfismyip.com/text -O - -q ; echo
95.54.96.122


There is many services which will give you external ip back (for example also ipecho.net, ifconfig.me, etc). Some of them always down, some so popular that flooded all the time and slow. But that one on example at least works right now.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IP address in CLI
Just popping in
Just popping in


See User information
@JosDuchIt

What command in CLI do i use for Shownetstatus i will need to scrape external IP ?

Go to top
Re: IP address in CLI
Just popping in
Just popping in


See User information
@jabirulo

From CLI ? I specifically asked for CLI so I can reuse the IP address in an application.

Go to top
Re: IP address in CLI
Just popping in
Just popping in


See User information
@kas1e

I know of wget / curl, but did not want to use too many reliance of other tools.

I was hoping for a command like :

IP -showinternalip
192.168.0.3

IP -showexternalip
21.109.49.208

I had hoped we had mature internet tools :(


Go to top
Re: IP address in CLI
Just can't stay away
Just can't stay away


See User information
@angelheart
Quote:
What command in CLI do i use for Shownetstatus i will need to scrape external IP ?


ShowNetStatus IS the command.

use this to get just the local IP address:

cut "`shownetstatus`" w=16

> cut "`shownetstatus`" w=16
192.168.1.101

Note: use use backquotes around shownetstatus.

Another way to use wget to create and envvar would be:

wget http://wtfismyip.com/text -O - -q >env:ExternalIP

same applies for the cut command:

cut "`shownetstatus`" w=16 >env:InternalIP

This is not the recommended way to create envvars but until we get recursive command embedding it will have to do.

It would be nice to be able to do things like:

SetENV InternalIP `cut "`shownetstatus`" w=16`

Amiga user since 1985
AOS4, A-EON, IBrowse & Alinea Betatester

Ps. I hate the new amigans website. <shudder>
Go to top
Re: IP address in CLI
Not too shy to talk
Not too shy to talk


See User information
@angelheart
and which command do you use on others operating systems?

Go to top
Re: IP address in CLI
Amigans Defender
Amigans Defender


See User information
@angelheart

Quote:
I know of wget / curl, but did not want to use too many reliance of other tools.

I was hoping for a command like :

IP -showinternalip
192.168.0.3

IP -showexternalip
21.109.49.208

I had hoped we had mature internet tools :(


No tool can show you your external IP address, as your computer has no idea what it is itself - only its own (LAN) one. Only your router (and any external site it contacts) will know what the external IP is.

The only way to do it is how kas1e said - and that goes for all other OS too.

Go to top
Re: IP address in CLI
Home away from home
Home away from home


See User information
@angelheart

there is the http handler, but I don't think its mounted by default.

using the http handler you should be able download web pages whit out curl/wget.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: IP address in CLI
Just can't stay away
Just can't stay away


See User information
@angelheart

Quote:
I know of wget / curl, but did not want to use too many reliance of other tools.


That's how other systems do it, they just use something like libcurl.so instead of calling curl itself. Part of the reason 'mainstream OS' packages are so big.

NO other OS developer is going to write any code if there is a .so or .dll around that does what they need, no matter how bloated it is and how little of it they will use.

99% of modern software development is all about money not elegance.

Amiga user since 1985
AOS4, A-EON, IBrowse & Alinea Betatester

Ps. I hate the new amigans website. <shudder>
Go to top
Re: IP address in CLI
Amigans Defender
Amigans Defender


See User information
@LiveForIt

Yep:
Quote:
1.> type http://wtfismyip.com/text
xx.xx.xx.xx


But installing that is more work than distributing a copy of curl along with whatever it is that is calling it.

If this is only for personal use however, whatever works and is convenient is the right way.

Go to top
Re: IP address in CLI
Just can't stay away
Just can't stay away


See User information
@angelheart

Ooops, sorry mate.

Think only method we have now is kas1e/Severin posted (or maybe with an ARexx script that uses wget/curl/TCP:).

Go to top
Re: IP address in CLI
Home away from home
Home away from home


See User information
@angelheart
to summorise everything: you need tosend http req to some external site, to know external ip.

if you want less as possible components involved, you then can do all on C without problems: you fill ip and tcp structs, and via sock-send-recv functions grab the answer. the only problem, is those public sites which give you info about your external ip (they offten down, slow and co). if you need example on C i can cook one.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 3 ( 0 members and 3 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project