如何在 Ubuntu 中配置路由以便仅在本地网络中使用网卡

如何在 Ubuntu 中配置路由以便仅在本地网络中使用网卡

我有带两张网卡的 Ubuntu 12.04。出于组织安全性考虑,我需要使用一张网卡将其连接到网络 10 内的流量。.*,另一个可以访问互联网。

如果我打开网络管理器并选择“仅将此连接用于网络中的资源”,一切都会顺利......直到......

我在该服务器中的 IP 是 10.5.24.*,因此如果某人的 IP 是 10.5.尝试连接到服务器,它不会应答,因为只有当您拥有 10.5 内的一个 IP 时才能访问该网络。我如何在网络管理器中添加一条路由来应答 10。.*?

在此先感谢您的帮助!

编辑

@david-go 这是我当前的配置:

IP Address: 10.58.24.35
Broadcast: 10.58.31.255
Subnet Mask: 255.255.248.0
Gateway: 10.58.24.1
DNS: 10.58.8.101

如果我选中“仅将此连接用于您网络中的资源”复选框,则网络 10.58.24.* 中的每个人都可以访问服务器,但问题是当网络中的某个人(例如:10.58.7.*)尝试访问它时。由于“我的网络”是 10.58.24.*,因此服务器不会响应请求。

编辑2

信息:来自(/sbin/ifconfig;/sbin/route -n)

eth0      Link encap:Ethernet  direcciónHW 18:03:73:d6:f8:bf  
          Direc. inet:10.58.24.35  Difus.:10.58.31.255  Másc:255.255.248.0
          Dirección inet6: fe80::1a03:73ff:fed6:f8bf/64 Alcance:Enlace
          ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST  MTU:1500  Métrica:1
          Paquetes RX:4643576 errores:0 perdidos:0 overruns:0 frame:0
          Paquetes TX:1981118 errores:0 perdidos:0 overruns:0 carrier:0
          colisiones:0 long.colaTX:1000 
          Bytes RX:1035692649 (1.0 GB)  TX bytes:1286344748 (1.2 GB)
          Interrupción:20 Memoria:e1a00000-e1a20000 

lo        Link encap:Bucle local  
          Direc. inet:127.0.0.1  Másc:255.0.0.0
          Dirección inet6: ::1/128 Alcance:Anfitrión
          ACTIVO BUCLE FUNCIONANDO  MTU:16436  Métrica:1
          Paquetes RX:876450 errores:0 perdidos:0 overruns:0 frame:0
          Paquetes TX:876450 errores:0 perdidos:0 overruns:0 carrier:0
          colisiones:0 long.colaTX:0 
          Bytes RX:136458162 (136.4 MB)  TX bytes:136458162 (136.4 MB)

wlan0     Link encap:Ethernet  direcciónHW 00:14:d1:21:a7:73  
          Direc. inet:172.16.115.133  Difus.:172.16.119.255  Másc:255.255.248.0
          Dirección inet6: fe80::214:d1ff:fe21:a773/64 Alcance:Enlace
          ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST  MTU:1500  Métrica:1
          Paquetes RX:64840 errores:0 perdidos:113 overruns:0 frame:0
          Paquetes TX:880 errores:0 perdidos:6 overruns:0 carrier:0
          colisiones:0 long.colaTX:1000 
          Bytes RX:9839656 (9.8 MB)  TX bytes:195993 (195.9 KB)

Tabla de rutas IP del núcleo
Destino         Pasarela        Genmask         Indic Métric Ref    Uso Interfaz
0.0.0.0         172.16.112.6    0.0.0.0         UG    0      0        0 wlan0
10.58.24.0      0.0.0.0         255.255.248.0   U     1      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
172.16.112.0    0.0.0.0         255.255.248.0   U     2      0        0 wlan0

编辑3

这是 lspci 的结果:

lspci
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04)
00:16.3 Serial controller: Intel Corporation 6 Series/C200 Series Chipset Family KT Controller (rev 04)
**00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)**
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4)
00:1c.2 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 3 (rev b4)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev a4)
00:1f.0 ISA bridge: Intel Corporation Q65 Express Chipset Family LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller (rev 04)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)

和 lsusb

lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
**Bus 001 Device 007: ID 0bda:8172 Realtek Semiconductor Corp. RTL8191SU 802.11n WLAN Adapter**
Bus 002 Device 003: ID 046d:c05a Logitech, Inc. Optical Mouse M90
Bus 002 Device 004: ID 413c:2107 Dell Computer Corp. 

答案1

最后我终于完成了。我必须添加到路线中:

route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.58.24.1 eth0

这使得 10.0.0.0 中的所有内容都通过eth0;并且:

route add -net 0.0.0.0 netmask 0.0.0.0 gw 172.16.112.6 wlan0

这使得其他一切都通过wlan0

相关内容