-3

A host with IP address 10.100.100.100 wants to use loopback testing,WHAT are the source and destination addresses?

  • 10.100.100.100 & 10.100.100.100
  • 10.100.100.100 & 255.255.255.255
  • 10.100.100.100 & 127.1.100.1
  • 127.100.100.100 & 10.100.100.100

We know that Loop Back testing means Source and Destination should be same. According to me option 1 and 3 both are right. Don't know which option is right.

2
  • This is a homework question, isn't it? Aug 31 '21 at 4:23
  • I’m voting to close this question because it appears to be a homework/test question - please take the time to research how to answer the question.
    – JW0914
    Aug 31 '21 at 12:37
0

All of the combiantions could be used for a loopback test, at least in Linux, since in what cases will loopback occur pretty much entirely depends on the type local routes in the route table local (ID 255). Those routes determine what addresses you can bind/use as source address and what traffics will be "trapped" in the host itself (instead of actually being sent / forwarded out to another host).

$ sudo ip r add local 10.100.100.100 dev lo src 10.100.100.100

(You can use e.g. dev eth0 for the above as well. In the unicast case the specified interface of a local route does not seem to matter. It appears to cause a difference for certain broadcast destination though, like 255.255.255.255, probably because it is used to determine the broadcasting link/domain in such case.)

$ ip r show table local type local
local 10.100.100.100 dev lo scope host src 10.100.100.100
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
local 192.168.1.143 dev eth0 proto kernel scope host src 192.168.1.143

(src is the preferred source address, which will be used as the source address for non-replying traffics with the corresponding destination when you are not specifying one, e.g. ping without -I some_address.)

$ ping -c 1 10.100.100.100
PING 10.100.100.100 (10.100.100.100) 56(84) bytes of data.
64 bytes from 10.100.100.100: icmp_seq=1 ttl=64 time=0.193 ms

--- 10.100.100.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.193/0.193/0.193/0.000 ms
$ ping -c 1 -I 10.100.100.100 127.1.100.1
PING 127.1.100.1 (127.1.100.1) from 10.100.100.100 : 56(84) bytes of data.
64 bytes from 127.1.100.1: icmp_seq=1 ttl=64 time=0.209 ms

--- 127.1.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.209/0.209/0.209/0.000 ms
$ ping -c 1 -I 127.100.100.100 10.100.100.100
PING 10.100.100.100 (10.100.100.100) from 127.100.100.100 : 56(84) bytes of data.
64 bytes from 10.100.100.100: icmp_seq=1 ttl=64 time=0.223 ms

--- 10.100.100.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.223/0.223/0.223/0.000 ms
$ sudo sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=0
net.ipv4.icmp_echo_ignore_broadcasts = 0
$ ping -c 1 -I 10.100.100.100 -b 255.255.255.255
PING 255.255.255.255 (255.255.255.255) from 10.100.100.100 : 56(84) bytes of data.
64 bytes from 10.100.100.100: icmp_seq=1 ttl=64 time=0.199 ms

--- 255.255.255.255 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.199/0.199/0.199/0.000 ms

And the following is the corresponding output from tcpdump running on same host at the same time:

$ sudo tcpdump -eni any icmp
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
16:50:01.183360 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 10.100.100.100 > 10.100.100.100: ICMP echo request, id 29, seq 1, length 64
16:50:01.183422 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 10.100.100.100 > 10.100.100.100: ICMP echo reply, id 29, seq 1, length 64
16:50:19.194256 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 10.100.100.100 > 127.1.100.1: ICMP echo request, id 30, seq 1, length 64
16:50:19.194321 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 127.1.100.1 > 10.100.100.100: ICMP echo reply, id 30, seq 1, length 64
16:50:43.600107 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 127.100.100.100 > 10.100.100.100: ICMP echo request, id 31, seq 1, length 64
16:50:43.600173 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 10.100.100.100 > 127.100.100.100: ICMP echo reply, id 31, seq 1, length 64
16:51:24.764481 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 10.100.100.100 > 255.255.255.255: ICMP echo request, id 32, seq 1, length 64
16:51:24.764548 lo    In  ifindex 1 00:00:00:00:00:00 ethertype IPv4 (0x0800), length 104: 10.100.100.100 > 10.100.100.100: ICMP echo reply, id 32, seq 1, length 64

By default you are not allowed to bind an address that is not covered as a destination by any local route:

$ ping -I 192.168.1.123 127.0.0.1
ping: bind: Cannot assign requested address

(Although there's a sysctl that you can use to make it possible, AFAIK.)

Because a local route is added for 127.0.0.0/8 automatically (as the prefix route, because 127.0.0.1/8 is configured on lo whenever the virtual interface is up), you can use any address within the range between 127.0.0.1 and 127.255.255.254 (inclusive) as the source address. (127.0.0.0 is the subnet ID of 127.0.0.0/8 and 127.255.255.255 is the broadcast address of the IP subnet, therefore they should be avoided.)

While 127.0.0.0/8 are reserved as "loopback addresses", it does NOT mean loopback can only occur if an address from that block is involved.

2
  • Could delete this Downvoted question? I generate new question here .Could you please answer here..cs.stackexchange.com/questions/143565/…
    – Alok Maity
    Aug 31 '21 at 9:27
  • Well, it could get downvoted there as well, because the way you ask it shows/hints that it's a homework question.
    – Tom Yan
    Aug 31 '21 at 9:31
0

127.0.0.0/8 (i.e. 127.0.0.0-127.255.255.255, subnet ID and broadcast address included, if those make sense in loopback) are the true loopback addresses, which are resolved on the network card itself. Though 127.0.0.1 is reserved by InterNIC for use in testing network cards, I've found that those other IP addresses allow for testing multiple destinations.

Though one might call 10.100.100.100 a "loopback" address, that is not the common term for the PC's own IP.

255.255.255.255 is a broadcast mask to all on the local network.

8
  • on the network card itselfI don't think they have anything to do with a network card, unless you are referring to the virtual loopback interface, which typically have 127.0.0.1 configured
    – Tom Yan
    Aug 31 '21 at 3:39
  • @Tom source ip- 10.100.100.100, destination ip- 10.100.100.100 can be treated as loop back?
    – Alok Maity
    Aug 31 '21 at 4:18
  • Yes. At least in Linux, a host will have a local route for addresses configured on its interfaces, so traffics with such destinations will not leave the host but be looped back by the OS. (The routes will have preferred source address that are identical to their destination.) Try ip r show table local type local if you are on Linux.
    – Tom Yan
    Aug 31 '21 at 4:55
  • For the record though, local routes are not specifically for looping back traffics, but rather they are for making traffics "land" (instead of going / being forwarded out) on this host generally.
    – Tom Yan
    Aug 31 '21 at 5:02
  • @Tom source ip-10.100.100.100 & destination ip-127.1.100.1 can be treated as loop back?
    – Alok Maity
    Aug 31 '21 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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