LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-21-2019, 12:32 PM   #1
andre88
LQ Newbie
 
Registered: Mar 2019
Posts: 20

Rep: Reputation: Disabled
Ping between virtual interface on the same machine


Hi,
I have two virtual interfaces, called tun_srsue and srs_spgw_sgi, with IP 172.16.0.2 and 172.16.0.1 respectively:

--------------------------------------------------------------------------
$ ifconfig
[...]
srs_spgw_sgi: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 172.16.0.1 netmask 255.255.255.0 destination 172.16.0.1
inet6 fe80::9dbf:b459:e809:1488 prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 6 bytes 468 (468.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9 bytes 432 (432.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

tun_srsue: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 172.16.0.2 netmask 255.255.255.0 destination 172.16.0.2
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6 bytes 468 (468.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[...]
--------------------------------------------------------------------------

I would like to try to ping each other from the host machine, and it works if I use the IP addresses:

--------------------------------------------------------------------------
$ ping -I 172.16.0.2 172.16.0.1 -c 5
PING 172.16.0.1 (172.16.0.1) from 172.16.0.2 : 56(84) bytes of data.
64 bytes from 172.16.0.1: icmp_seq=1 ttl=64 time=0.059 ms
64 bytes from 172.16.0.1: icmp_seq=2 ttl=64 time=0.075 ms
64 bytes from 172.16.0.1: icmp_seq=3 ttl=64 time=0.086 ms
64 bytes from 172.16.0.1: icmp_seq=4 ttl=64 time=0.057 ms
64 bytes from 172.16.0.1: icmp_seq=5 ttl=64 time=0.055 ms

--- 172.16.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4086ms
rtt min/avg/max/mdev = 0.055/0.066/0.086/0.014 ms
--------------------------------------------------------------------------

It doesn't work instead if I use the interface's name:

--------------------------------------------------------------------------
$ ping -I tun_srsue 172.16.0.1 -c 5
PING 172.16.0.1 (172.16.0.1) from 172.16.0.2 tun_srsue: 56(84) bytes of data.

--- 172.16.0.1 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4077ms
--------------------------------------------------------------------------

In the first case, Wireshark doesn't see anything monitoring srs_spgw_sgi, in the second case it captures the five ICMP packets arriving to srs_spgw_sgi (but with "no response seen" warning).

I have removed all rp filtering and enabled ip forwarding (net.ipv4.ip_forward).

I don't understand why does not work in the second case... could you help me?

Thank you!!

Andrea

Last edited by andre88; 03-26-2019 at 06:05 AM. Reason: I inverted the two cases in the sentence about Wireshark
 
Old 03-25-2019, 03:16 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
The second case need to resolve interface name. When the name is resolving, routing has problem.
 
Old 03-25-2019, 03:23 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Notes.

Ping isn't a very good way to test.

Ping using ipv4 in this case will need to have the host and clients able to communicate either within the same subnet or by all having the correct routing (as above). However there is also the question of how you configured the virtual nic in the vm settings as they may have an impact.

Why don't you just use a simple ping ip address?
 
Old 03-26-2019, 06:15 AM   #4
andre88
LQ Newbie
 
Registered: Mar 2019
Posts: 20

Original Poster
Rep: Reputation: Disabled
Hi, thank you for your answers!
First of all: I have edited the thread, because I inverted the two cases in the sentence about Wireshark. Now it's right!

@nini09: what do you mean about resolving interface name? What should I do? I tried to add

172.16.0.1 srs_spgw_sgi
172.16.0.2 tun_srsue

to /etc/hosts and even to /etc/network/interfaces, both together and also alternatively, but this did not work.

@jefro: what do you mean with "simple ping ip address"? Something like the first test I made?

Sorry guys but I'm a beginner on both Linux and networking! Thank you!!

Andrea
 
Old 03-26-2019, 02:44 PM   #5
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
That is dependant on the implementation of ping tool, how does it map interface name to IP address.
Normally, we shouldn't use the option of forcing source interface, using routing table is correct way.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ping between two interfaces in the same machine Ivv Linux - Networking 4 09-06-2013 03:47 PM
Can't Ping betwen interface on Virtual Machine nerka Linux - Networking 7 11-28-2011 12:39 PM
I cannot ping with command 'ping IP' address but can ping with 'ping IP -I eth0' sanketmlad Linux - Networking 2 07-15-2011 05:32 AM
[SOLVED] Ping between 2 eth ports on the same machine ritu.kaur Linux - Networking 2 09-25-2010 08:33 AM
prevent users to run the same script at the same time, on the same machine pvpnguyen Programming 2 09-05-2007 08:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration