How to get IP address without curl

Pavol Travnik
Nov 9, 2020
get IP address in cli without curl

In case you don’t want to install curl via apt get curl on alpine, debian or ubuntu operating system, you can use netcat instead which is preinstalled.

With curl, you could use:

curl https://ifconfig.me/

But using printf, nc and tail you can get the same result:

printf "GET / HTTP/1.1\r\nHost: ifconfig.me\r\nUser-Agent: curl/7.64.1\r\nAccept: */*\r\n\r\n" | nc ifconfig.me 80 | tail -n1

This can happen f.e. if you have access to the user account, but you don’t have root access via sudo.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Pavol Travnik
Pavol Travnik

No responses yet

Write a response