Identifying the running linode

It is possible to identify the running linode by its ID from /etc/network/interfaces as generated by Linode Network Helper.

e.g.

linode_id="$(grep 'https://cloud.linode.com/linodes/' /etc/network/interfaces | grep -E -o '[0-9]+')"

However this could eaasily be broken by a change to the Linode Network Helper.

Is there a better, safer way?

2 Replies

Take a look at the Linode API

This is an issue I’ve tried to figure out in the past too. The API is the best way to retrieve details about your Linodes - but what you need is a way to identify the Linode on which code/script is running.

The only way I can think is comparing the primary IP of eth0 with the public IP given in the API results, and working out it that’s the one you want - e.g. by tag or name/label.

I have heard rumours of a metadata service which would allow a Linode to query information about itself, so it could probably find out it’s own ID, but I don’t know where this is up to on Linode’s plans.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct