正确配置两个网卡,以便我可以在Linux上同时访问它们

正确配置两个网卡,以便我可以在Linux上同时访问它们

我是 Linux 的初学者(我使用的是 CentOS 7)。我有一个带有两个网卡的工作站。我将它们配置为每个都有自己的 WAN。但是,我无法同时访问(使用 ping)它们。

  • 第一个广域网:172.16.0.1
  • 第二个广域网:10.101.0.10

请查看以下输出以了解更多详细信息:

[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 <[email protected]>
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.

请注意,IP 10.127.111.1 与 GW:172.16.0.1 的专线相关。当我关闭第二个网卡(WAN:10.101.0.10)时,10.127.111.1 重播。我怎样才能从这两张卡收到。

多谢 :)

相关内容