Article 6DCN4 I can ping with the NIC IP, but not with the NIC name

I can ping with the NIC IP, but not with the NIC name

by
Jason.nix
from LinuxQuestions.org on (#6DCN4)
Hello,
I have a Debian box with two NAT NICs as below:
Code:# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe7b:8f51 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:7b:8f:51 txqueuelen 1000 (Ethernet)
RX packets 3636 bytes 406457 (396.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2629 bytes 390382 (381.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.3.15 netmask 255.255.255.0 broadcast 10.0.3.255
inet6 fe80::a00:27ff:fe26:19c3 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:26:19:c3 txqueuelen 1000 (Ethernet)
RX packets 778 bytes 313043 (305.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 757 bytes 165063 (161.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 135 bytes 19036 (18.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 135 bytes 19036 (18.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0One of the NIC takes the IP from DHCP and one of them is static:
Code:# cat /etc/network/interfaces

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp0s3
iface enp0s3 inet static
address 10.0.2.15
netmask 255.255.255.0
gateway 10.0.2.2

allow-hotplug enp0s8
iface enp0s8 inet dhcpAnd:
Code:# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 enp0s3
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3
10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s8I tried to ping Google.com:
Code:# ping -I enp0s3 google.com
PING google.com (216.239.38.120) from 10.0.2.15 enp0s3: 56(84) bytes of data.
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=1 ttl=63 time=38.8 ms
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=2 ttl=63 time=41.5 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 38.792/40.128/41.465/1.336 ms
#
# ping -I enp0s8 google.com
PING google.com (216.239.38.120) from 10.0.3.15 enp0s8: 56(84) bytes of data.I can ping Google.com via enp0s3 NIC because of the default gateway, but with enp0s8 NIC it is not possible and I must use its IP:
Code:# ping -I 10.0.3.15 google.com
PING google.com (216.239.38.120) from 10.0.3.15 : 56(84) bytes of data.
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=1 ttl=63 time=26.8 ms
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=2 ttl=63 time=25.4 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 25.412/26.127/26.773/0.582 msWhy?

Thank you.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments