0

I have two NIC on my system with centos 7 as OS. One interface is public with ip 172.68.122.120 (em1) and second with ip 10.11.15.20 (p4p1). Now When I reboot my system, bydefault, public ip is not going to ping while private ip can be ping within the subnet. Then I make my private interface down and then up again. Now both IPs are going to ping. What is the problem ? I think there is some priority issue in NICs. If I run netstat -rn command I get following output at boot time.

0.0.0.0         10.11.15.1      0.0.0.0         UG        0 0          0 p4p1
0.0.0.0         172.68.122.10  0.0.0.0         UG        0 0          0 em1 

After resetting my private interface. Above output for command netstat -rn is changed to following

0.0.0.0         172.68.122.10  0.0.0.0         UG        0 0          0 em1
0.0.0.0         10.11.15.1      0.0.0.0         UG        0 0          0 p4p1

what is the problem and how I can solve it ?

1
  • 1
    Please post the /etc/sysconfig/network-scripts/ifcfg-* of both interfaces.
    – dawud
    May 30, 2016 at 10:32

1 Answer 1

2

It looks like you have two default routes, when the machine comes up the internal interface is enabled first and so that default route comes first (ie has priority) in the routing table. This then routes your ICMP echo replies via your internal network and not the external one. One test for this would be to check whether you can ping the public IP from another machine on the same subnet - if that works, then it's a routing issue. When you restart the internal interface, the external interface comes first in the routing table and so pinging works properly.

The solution is to remove the default gateway from the internal interface in your configuration - the machine only needs (indeed, should only have) one default gateway.

2
  • If I remove internal interface gateway route, then how I will be able to access my system from private IP Jun 1, 2016 at 7:26
  • You don't need a route to access other machines on the same subnet. If you have an internal network with various subnets, you'll need to create static routes to those via the router on your internal network. Assuming that all traffic from the machine to the Internet and vice versa should go via the public interface, then having a default gateway on that interface and no gateway on the private interface is the correct configuration.
    – Edd
    Jun 1, 2016 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .