The best command that shows to which server the IP is routed?

postcd

Member
Joined
Jul 8, 2017
Messages
37
Reaction score
3
Credits
89
Hello,

what is the good Linux command that shows an IP address of the server to which an IP or IP subnet is assigned?

I know the assigned IP, but not the IP or subnet of the server to which this IP is routed/assigned. Which command will show that to me please?

I would like to detect the moment when an IP is re-assigned to different server.
 


Hello,

what is the good Linux command that shows an IP address of the server to which an IP or IP subnet is assigned?

I know the assigned IP, but not the IP or subnet of the server to which this IP is routed/assigned. Which command will show that to me please?

I would like to detect the moment when an IP is re-assigned to different server.

No sure I understands what you are looking for here but I can give you something.

You can use either ifconfig or ip address to get information about the ip address of an interface and what the net mask is.

With ifconfig the information you would be looking for is:
Code:
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.5.32.50  netmask 255.255.224.0  broadcast 10.5.63.255
        inet6 fe80::7aac:c0ff:feb2:d109  prefixlen 64  scopeid 0x20<link>
        ether 78:ac:c0:b2:d1:09  txqueuelen 1000  (Ethernet)
        RX packets 48538111  bytes 4537606432 (4.2 GiB)
        RX errors 0  dropped 2183  overruns 0  frame 0
        TX packets 623876  bytes 294979474 (281.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xf0500000-f0520000

The information that would be important for you from above is inet 10.5.32.50 netmask 255.255.224.0

Or
Code:
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 78:ac:c0:b2:d1:09 brd ff:ff:ff:ff:ff:ff
    inet 10.5.32.50/19 brd 10.5.63.255 scope global enp0s25
       valid_lft forever preferred_lft forever
    inet6 fe80::7aac:c0ff:feb2:d109/64 scope link
       valid_lft forever preferred_lft forever

Of which the following is the important information inet 10.5.32.50/19

Both give you information about what network you belong to. These are networks not servers. Servers belong to a network and are assigned IP Addresses form that network.

The netmask (from the first example) or the /## (from the second example) are the part that tell you how big the network is and how many hosts can be assigned to it.

If you are looking for the gateway (how you leave one network and get to another) then you want to look at the routing table:

Code:
[COLOR=rgb(0, 0, 0)]Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.5.32.1       0.0.0.0         UG    100    0        0 enp0s25
10.5.32.0       0.0.0.0         255.255.224.0   U     100    0        0 enp0s25

Here you can see your network, in my case 10.5.32.0 and it say if I want to go to another network I need to use the 0.0.0.0 which is located on 10.5.32.1 which is the gateway.

Not sure if this answered your questions or not.
[/COLOR]
 

Members online


Latest posts

Top