Identity

Hi there! Would like to get my local gateway IP to mikrotik identity. How can i do that?

If I’m understanding your question correctly, you’re trying to set your Mikrotik device identity to the local IP of your gateway.

Making the following assumptions:

  • Your trying to set the identity of a device that is not your gateway
  • You only have one route to worry about

You can set the identity of your device with

/system identity set name=<NAME>

Assuming a simple network, you’re only going to have one line of output for ‘/ip route nexthop print’, so you can get your gateway’s local IP with

/ip route nexthop get 0 address

Knowing that, you can get your identity to your gateway’s local IP with

/system identity set name=[/ip route nexthop get 0 address]

If you potentially have more than one line of output for /ip route nexthop print, you can grab the address for the line with a reachable gateway with

/ip route nexthop get [/ip route nexthop find where gw-state=reachable] address]

Now let’s assume a different topology:

  • You have a Mikrotik device directly behind your ISP gateway
  • You want to set your Mikrotik device identity to the internal (LAN) IP of your ISP gateway (your “gateway” from a routing perspective)

The same line works :smiley:

/system identity set name=[/ip route nexthop get 0 address]

The next hop from your Mikrotik device on the edge to your ISP gateway will be your ISP gateway’s customer-facing IP (not your public IP).


I hope one of those two scenarios answers your question, or at least gets you started.

Cheers