Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

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

Discussion in 'Linux Networking' started by postcd, Jul 21, 2017.

  1. postcd

    postcd New Member

    Jul 8, 2017
    Likes Received:

    (Log in to hide this advertisement)

    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.
  2. Lazydog

    Lazydog Member

    Jul 27, 2017
    Likes Received:
    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:
    enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet  netmask  broadcast
            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 netmask

    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 brd 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

    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:

    [COLOR=rgb(0, 0, 0)]Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    100    0        0 enp0s25   U     100    0        0 enp0s25
    Here you can see your network, in my case and it say if I want to go to another network I need to use the which is located on which is the gateway.

    Not sure if this answered your questions or not.

Share This Page