详细介绍双网卡内外网同时使用的方法

不少公司的网管试图解决双网卡问题,下面我就给大家详细的讲解一下双网卡同时使用的方法,这样即可保障内网的安全,又能解决电脑访问外网的问题,一举两得。希望大家喜欢。

首先你的机器需要有两块网卡,分别接到两台交换机上,

internet地址:192.168.1.8,子网掩码:255.255.255.0,网关:192.168.1.1

内部网地址:172.23.1.8,子网掩码:255.255.255.0,网关:172.23.1.1

如果按正常的设置方法设置每块网卡的ip地址和网关,再cmd下使用route print查看时会看到

Network Destination Netmask Gateway Interface Metric

0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.8

0.0.0.0 0.0.0.0 172.23.1.1 172.23.1.8

即指向0.0.0.0的有两个网关,这样就会出现路由冲突,两个网络都不能访问。

如何实现同时访问两个网络?那要用到route命令

第一步:route delete 0.0.0.0     "删除所有0.0.0.0的路由"

第二步:route add 0.0.0.0 mask 0.0.0.0 192.168.1.1     "添加0.0.0.0网络路由"这个是主要的,意思就是你可以上外网.

第三步:route add 172.23.0.0 mask 255.0.0.0 172.23.1.1    "添加172.23.0.0网络路由",注意mask为255.0.0.0   ,而不是255.255.255.0 ,这样内部的多网段才可用。

这时就可以同时访问两个网络了,但碰到一个问题,使用上述命令添加的路由在系统重新启动后会自动丢失,怎样保存现有的路由表呢?

route add -p 添加静态路由,即重启后,路由不会丢失。注意使用前要在tcp/ip设置里去掉接在企业内部网的网卡的网关

------------------------------------------------------------------------------------------------

一些单位将内网和外网分开了。痛苦啊,偶单位就是如此。boss当然是基于安全性考虑了,可是没有笔记本的怎么办?又要办公,有得上网。没办法,发扬DIY精神偷偷装一块网卡,让聊天与工作同在。让你的主机内外兼顾。这是我在网上找到的,谢谢作者了。方法如下:
1.设置其中接internet的网卡的网关为10.0.0.1,启用后就是默认网关
--注:这是对应外网的网卡,按照你们单位外网的ip分配情况,在TCP/IP属性中配置好 ip、掩码、DNS

2.将连接单位内部网的网卡IP配好后,设网关设置为空(即不设网关),启用后,此时内网无法通过网关路由

3.进入CMD,运行:route -p add 192.0.0.0 mask 255.0.0.0 192.168.0.1 metric 1

--注:意思是将192*的IP包的路由网关设为192.168.0.1 ,-P 参数代表永久写入路由表,建议先不加此参数,实践通过后在写上去

4. OK!同时启用两个网卡,两个网关可以同时起作用了,两个子网也可以同时访问了,关机重启后也不用重设!


其实这是个中折的办法。。。。使大家的双网卡同时运行,很不错的方法。大家学习一下吧。。

For Windows:
Edit the secondary network adapter. In the Ipv4 properties, click the radio button use the following IP Address. Insert an IP and subnet into the appropriate fields, such as 10.1.2.1 and 255.255.255.0.

Open a dos prompt and type in the following command:
route -p add Private-Network mask Private-Network-Mask Private-Interface-IP.

In the above example it would be: route –p add 10.1.2.0 mask 255.255.255.0 10.1.2.1

For Linux:
The following procedure uses eth1 as an example for assigning a TCP/IP address.

Use the following command to add the IP address (example):

ifconfig eth1 10.1.2.1 mask 255.255.255.0

Note that eth1 is in the secondary network adapter.

To make the changes permanent you will need to add the IP also in the network scripts which are being started on system boot.

1. Verify that your /etc/sysconfig/network-scripts/ifcfg-eth1 file does not have a GATEWAY= parameter in it.
2. View the route table and verify the private network route is there. Using the example above, the route should look like:

Destination Gateway Genmask Flags Metric Ref Use Iface
10.1.2.0 * 255.255.255.0 U 2 2 2 eth1

For FreeBSD:
1) Use ifconfig command as follows:
ifconfig interface inet IP

Example(s):

ifconfig fxp1 inet 10.1.2.1

Note fxp1 is Ethernet interface name can be Obtained using ifconfig -a command.

2) To setup up ip permanently open file /etc/rc.conf ; add/modify network entries:
vi /etc/rc.conf
ifconfig_fxp1="inet 10.1.2.1 netmask 255.255.255.0"

Note ifconfig_fxp1 is Ethernet interface name can be Obtained using ifconfig -a command.

3) Run /etc/netstart script.

 

posted on 2009-11-13 16:01  delphi2007  阅读(692)  评论(0编辑  收藏  举报