Home > front end >  How to get ip address of minion through which it is connected to master
How to get ip address of minion through which it is connected to master

Time:02-06

I want to retrieve IP address of minion through which it is communicating with master.

salt '*' network.ip_addrs
salt '*' cmd.run "curl ifconfig.me"
salt '*' cmd.run "curl -s icanhazip.com"

Using above commands minion returns ip addresses of all interfaces.

How to filter ip address to get the ip address through which it is connected to master

CodePudding user response:

If you know the subnet that the master and minion share:

salt '*' network.ip_addrs cidr=10.2.16.0/24

Otherwise, you can check the socket table:

salt '*' cmd.run "ss -nt | grep :4505 | awk '{print \$4}'"

CodePudding user response:

To filter the IP address of the network interface that a minion is using to communicate with the master, you can use the following SaltStack command on the master:

salt <minion_id> network.interface_ip <interface_name>

Replace <minion_id> with the ID of the minion, and replace <interface_name> with the name of the network interface you want to inspect.

For example, if the network interface name is eth0, you can use the following command:

salt <minion_id> network.interface_ip eth0

This command will return the IP address associated with the specified network interface. Note that the exact name of the network interface may vary depending on the operating system and configuration of the minion. You can use the network.interfaces command to get a list of all available network interfaces on a minion.

  • Related