---
title: "Setting the Gateway Hostname as a Variable in Geneos"
description: "The Gateway hostname is not available as a built-in variable in Geneos and must be manually defined. Users can create and access this variable in environments or managed entities for use in Sampler Toolkit scripts and rules."
url: "https://docs.itrsgroup.com/docs/faq/geneos/27811047798813-geneos-setting-the-gateway-hostname-as-a-variable-in-geneos/index.html"
---
## Problem

In Geneos, users may need to reference the **hostname of the Gateway server** as a variable, typically for use in Sampler Toolkit scripts or conditional configuration logic. However, there is **no built-in** `${gatewayHostname}` **macros** available like `${gatewayName}`

### Solution

The Gateway hostname must be manually defined as a variable, as it isn't available by default.

Example:

GSE > Environments > Geneos

![Geneos - Setting the Gateway Hostname as a Variable in Geneos](https://docscdn.itrsgroup.com/faq/images/geneos/27811047798813-inline-1-image.png)

Set the Env on your sampler where the toolkit is used:

![Geneos - Setting the Gateway Hostname as a Variable in Geneos](https://docscdn.itrsgroup.com/faq/images/geneos/27811047798813-inline-2-image.png)

Toolkit plugin setup:

![Geneos - Setting the Gateway Hostname as a Variable in Geneos](https://docscdn.itrsgroup.com/faq/images/geneos/27811047798813-inline-3-image.png)

Output:

![Geneos - Setting the Gateway Hostname as a Variable in Geneos](https://docscdn.itrsgroup.com/faq/images/geneos/27811047798813-inline-4-image.png)

**In Rules:**
If you've defined a variable containing the hostname, you can access it when creating a rule. In the rule setup window, right-click in the blank area, select **Variables**, and you should see your defined variable listed for use in the expression.

![Geneos - Setting the Gateway Hostname as a Variable in Geneos](https://docscdn.itrsgroup.com/faq/images/geneos/27811047798813-27811294220317-mceclip0.png)

**Note:**
The variables can be defined in managed entities, managed entity groups, types, environments, and operating environment: h[ttps://docs.itrsgroup.com/docs/geneos/current/processing/gateway-administration/gateway\_user\_variables\_and\_environments/index.html#define-variables](https://docs.itrsgroup.com/docs/geneos/current/processing/gateway-administration/gateway_user_variables_and_environments/index.html#define-variables)

## Related article(s)

- <https://docs.itrsgroup.com/docs/geneos/current/collection/toolkit-plugin/index.html#Heading-overview>
- [docs.itrsgroup.com/docs/geneos/current/processing/gateway-administration/gateway\_user\_variables\_and\_environments/index.html#environments--environment--var--macro](https://docs.itrsgroup.com/docs/geneos/current/processing/gateway-administration/gateway_user_variables_and_environments/index.html#environments--environment--var--macro)


