Ask Your Question
0

Get private IP with CLI

asked 2019-05-09 04:22:54 -0500

wolfv gravatar image

I am trying to get only the private IP v4 from the command line interface. I can use openstack server show myserver -c addresses just fine but it prints out a table / json and I am not able to find only the private v4 IP.

I'd like to have some command like

openstack server addresses -4 --private which would return

19.23.32.12

Is that implemented somewhere or do I need to write my own python script?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2019-05-09 06:53:50 -0500

I don't think you can do this without further processing, but you can change the output format to value:

openstack server show INSTANCENAME -c addresses -f value | cut -f2 -d=

The above assumes that there is a single IPv4 address and no IPv6 address.

You can also use output format json and pipe the output into a parser like jq. Output formats shell and yaml might also be interesting.

FInally, you could submit the API request with curl and, again, use jq to parse it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2019-05-09 04:22:54 -0500

Seen: 26 times

Last updated: May 09