Our company have a IDC (Internet Data Center), and in our IDC, there are many host machines, every host has 1-3 IPs.

There is a situation, such as one host machine has 3 IPs(eg. 102.23.33.1 -> 102.23.33.3). (means in the host machine, have configured the IPs to it)

If the host machine only use 102.23.33.1, and there free out the 102.23.33.2 and 102.23.33.3. We want to find out the free IPs.

How can I do that? I tried to use the forloop to ping the whole IPs, but this is not accurate, because some host machine are baned for ping.


EDIT

I means the host machine if has 3 IPs, and all can ping them, but the host machine only use the first IP to connect with public network, how can I find the other 2 IPs host machine do not use (or do not often use)?


EDIT-2

I mean the IPs all configured on the OS but may not be actually using them.


EDIT - 3

So, all the before, there can be understood as bellow:

I have a Router, and under it, there are many host machines, and every host machine have some IPs, and how can I record the IPs that go through the Router everyday.

Is there a tool for record the IPs which get through the Router? Or how can I realize my requirement ?

  • 1
  • You'll need to be more clear. Do you mean, the machines have IP addresses allocated on paper, but may not have them configured at the OS level, or that they're all configured on the OS but may not be actually using them? – EightBitTony Oct 17 '17 at 9:08
  • @EightBitTony The later. – 244boy Oct 17 '17 at 9:15
  • Then there's no easy answer - you need to analyse the traffic on each interface on each host, either at the host end or at the switch end (assuming they're real switches), or find some other network traffic management tool which will show you (iptables?) – EightBitTony Oct 17 '17 at 9:25
  • Or do you mean that you know the other two IP addresses are free? In which case, you need to (automate) logging on to each server and getting the network config. – EightBitTony Oct 17 '17 at 9:26

This adds a logging rule into the iptables FORWARD chain:

# iptables -I FORWARD -j LOG --log-prefix 'MYIPS: '

This searches for the matching packets:

# grep MYIPS /var/log/syslog

The file name may depend on your Linux distribution.

And this generates a list of unique IP addresses seen by the forwarding chain in your router:

# grep -oE '(SRC|DST)=[0-9.]*' /var/log/syslog | sed 's/.*=//' | sort -u

Still not clear. Your router is a Linux machine? or a networking device? You may check the dhcp lease list on your dhcp server if you are using a DHCP to assign the IP addresses. that will help you better.

  • The IPs is manual configuration. – 244boy Oct 18 '17 at 2:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.