Linux:
文件位置:
/etc/sysconfig/static-routes
内容:
eth0 net 192.168.0.0 netmask 255.255.0.0 gw 10.1.1.254
说明:
第一段eth0是网卡名,网上疯狂的是any,表示所有网卡
net 指示的为一个网络,而不是一台主机,可和host单机
gw 是关键字,有些Linux版本可以省略,大多数版本不可以。
FreeBSD
文件位置:
/etc/rc.conf
内容:
static_routes="test1 test2"
route_test1="-net 192.168.200.0/24 192.168.148.200"
route_test2="-net 192.168.300.0/24 192.168.148.300"
说明:
第一行定义了两个静态路由名称,多个用空格分隔就可以
第二行,route_后面跟的就是第一行定义的名称,FreeBSD的惯例,下划线前面是命令,后面是数。注意后面的值,net前面有个减号,其实这是route命令行后面的东西。另外跟Linux相比,没有gw关键字
第三行指明了另一个路由。
windows:
windows直接用命令:
C:\Documents and Settings\Administrator.PC>route -p add 10.73.40.0 mask 255.255.255.0 192.168.6.252
C:\Documents and Settings\Administrator.PC>netstat -nr
IPv4 Route Table
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...84 2b 2b 18 94 ad ...... Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #2 - VirtualBox Bridged Networking Driver Miniport
0x3 ...08 00 27 00 10 05 ...... VirtualBox Host-Only Ethernet Adapter
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.6.254 192.168.6.109 10
192.168.6.0 255.255.255.0 192.168.6.109 192.168.6.109 10
192.168.6.109 255.255.255.255 127.0.0.1 127.0.0.1 10
10.73.17.0 255.255.255.0 192.168.6.252 192.168.6.109 1
10.73.40.0 255.255.255.0 192.168.6.252 192.168.6.109 1
10.73.57.0 255.255.255.0 192.168.6.252 192.168.6.109 1
10.255.255.255 255.255.255.255 192.168.6.109 192.168.6.109 10
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
255.255.255.255 255.255.255.255 192.168.56.1 192.168.56.1 1
Default Gateway: 192.168.6.254
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
10.73.17.0 255.255.255.0 192.168.6.252 1
10.73.40.0 255.255.255.0 192.168.6.252 1
10.73.57.0 255.255.255.0 192.168.6.252 1
该贴被wulcan编辑于2014-12-26 11:15:07
该贴由hui.chen转至本版2015-1-5 10:17:05