networking – Configuring two network cards so that I can access them at the same time on Linux

I’m a bit of a beginner in Linux (I’m using CentOS 7). I have a workstation with two network cards. I configured them so that each has its own WAN. However, I can’t access (using ping) them at the same time.

  • 1st WAN: 172.16.0.1
  • 2nd WAN: 10.101.0.10

Please have a look at the following outputs for more details:

(root@localhost network-scripts)# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    101    0        0 ens192
default         gateway         0.0.0.0         UG    102    0        0 ens160
10.101.0.0      0.0.0.0         255.255.0.0     U     102    0        0 ens160
172.16.0.0      0.0.0.0         255.255.255.0   U     101    0        0 ens192
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0


Emad Helal <emadbadr2011@gmail.com>
00:22 (5 minutes ago)
to me

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:bf:9c:a5 brd ff:ff:ff:ff:ff:ff
    inet 10.101.3.44/16 brd 10.101.255.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::b66e:4822:ba8c:e806/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:bf:9c:af brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.8/24 brd 172.16.0.255 scope global noprefixroute ens192
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:febf:9caf/64 scope link
       valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:72:52:14 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:72:52:14 brd ff:ff:ff:ff:ff:ff
(root@localhost network-scripts)# ping www.google.com
PING www.google.com (216.58.205.196) 56(84) bytes of data.
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=1 ttl=115 time=38.1 ms
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=2 ttl=115 time=38.1 ms
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=3 ttl=115 time=38.1 ms
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=4 ttl=115 time=38.1 ms
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=5 ttl=115 time=38.2 ms
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=6 ttl=115 time=38.4 ms
64 bytes from mrs09s09-in-f4.1e100.net (216.58.205.196): icmp_seq=7 ttl=115 time=38.2 ms
^C
--- www.google.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6007ms
rtt min/avg/max/mdev = 38.117/38.215/38.482/0.119 ms
(root@localhost network-scripts)# ping 172.16.0.1    
PING 172.16.0.1 (172.16.0.1) 56(84) bytes of data.
64 bytes from 172.16.0.1: icmp_seq=1 ttl=255 time=1.64 ms
64 bytes from 172.16.0.1: icmp_seq=2 ttl=255 time=0.536 ms
64 bytes from 172.16.0.1: icmp_seq=3 ttl=255 time=0.536 ms
64 bytes from 172.16.0.1: icmp_seq=4 ttl=255 time=0.554 ms
64 bytes from 172.16.0.1: icmp_seq=5 ttl=255 time=0.554 ms
64 bytes from 172.16.0.1: icmp_seq=6 ttl=255 time=0.552 ms
64 bytes from 172.16.0.1: icmp_seq=7 ttl=255 time=0.550 ms
^Z
(1)+  Stopped                 ping 172.16.0.1
(root@localhost network-scripts)# ping 10.127.111.1
PING 10.127.111.1 (10.127.111.1) 56(84) bytes of data.

Please, note that the IP 10.127.111.1 is related to the leased-line with GW: 172.16.0.1. When i close the second network card (WAN: 10.101.0.10) 10.127.111.1 replays. How can i receive from both cards.

Thanks a lot 🙂