2024年3月21日发(作者:)
route命令详解与使用实例
1. 使用背景
笔者在出差调试的过程中,常常会遇到这样的情况:需要接入两个网络,一个是部署
环境所在内网环境,这个环境是上不了外网,但是为了跟同事的沟通,常常还需要外网环
境,这个外网环境很可能是一个无线网络。如果两者都连接上,很可能导致有一方不能起
作用,即外网或内网上不了,常常需要使用繁琐的“禁用网络连接”、“启用网络连接”的
操作来进行内外网的切换,甚是麻烦。
为了解决这个问题,我们可以使用route命令来使得同时内外网都可用。
2. route命令
route命令是在本地 IP 路由表中显示和修改条目网络命令。
route命令的语法如下:
route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric M
etric]] [if Interface]]
route命令常用的命令如下:
1)route delete:删除路由;
2)route print:打印路由的Destination;
3)route add:添加路由;
4)route change:更改现存路由。
一般使用route delete、route add、route print这三条命令可解决路由的所有功
能。
2.1 打印路由信息
打印路由信息使用命令:route print。
例如笔者在工作环境下打印route print命令,结果如下:
C:"Documents and Settings"阿蜜果>route print
=================================================
==========================
Interface List
0x1 MS TCP Loopback interface
0x2 00 26 18 31 4f d1
er
Realtek RTL8168C(P)/8111C(P) PCI-E Gigabit Eth


发布评论