V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
clino
V2EX  ›  问与答

网络 IT 问题:一个网段上有个交换机(配置成网关)和一个路由器,那么 traceroute 会走哪个是不是完全由交换机和路由器的配置所决定?

  •  
  •   clino · 2014-07-14 18:22:30 +08:00 · 4265 次点击
    这是一个创建于 3566 天前的主题,其中的信息可能已经有所发展或是发生改变。
    还是跟本机的配置缓存之类的会有关系?
    具体问题是碰到一次IT帮忙把去往某个IP的路由改成走路由器,之后有问题又改回来了,但用traceroute测试就死活走的是路由器而不是网关,如何理解这是哪里出的问题呢?
    9 条回复    2014-07-15 15:49:11 +08:00
    a2z
        1
    a2z  
       2014-07-14 18:34:57 +08:00
    交换机怎么做网关?3层交换机用的SVI?
    如果有两个网关的话,那就要看本机配置的网关地址是多少了,是哪个就走哪里。
    109109
        2
    109109  
       2014-07-14 18:42:14 +08:00
    traceroute 首先查找路由表,如果没有对应的,再走默认网关
    icqdany
        3
    icqdany  
       2014-07-14 18:42:41 +08:00
    本地路由表
    clino
        4
    clino  
    OP
       2014-07-14 20:42:32 +08:00 via Android
    @109109 @icqdany 本地路由表怎么查? 之前其实查过,但感觉很简单没什么信息
    clino
        5
    clino  
    OP
       2014-07-14 20:44:23 +08:00 via Android
    @a2z 交换机做网关这个我不知道有没有弄错 不过traceroute第一跳不走网关是真的有
    princeofwales
        6
    princeofwales  
       2014-07-14 21:14:12 +08:00
    @clino windows:route print Linux:ip route
    优先级静态路由>默认路由
    clino
        7
    clino  
    OP
       2014-07-15 09:04:40 +08:00
    @109109
    @icqdany
    @princeofwales

    网络设置
    root@shserver1:~# cat /etc/network/interfaces
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth2
    iface eth2 inet static
    address 10.4.69.150
    netmask 255.255.255.0
    network 10.4.69.0
    broadcast 10.4.69.255
    gateway 10.4.69.2

    如上面提到的ip route结果
    root@shserver1:~# ip route
    default via 10.4.69.2 dev eth2 metric 100
    10.4.69.0/24 dev eth2 proto kernel scope link src 10.4.69.150

    traceroute异地一台机器第一跳不是网关
    root@shserver1:~# traceroute xmserver1
    traceroute to xmserver1 (10.125.159.218), 30 hops max, 60 byte packets
    1 10.4.69.8 (10.4.69.8) 1.469 ms 1.666 ms 1.908 ms
    2 * * *
    3 xmserver1 (10.125.159.218) 33.137 ms 33.114 ms 33.067 ms

    另一台机器则是网关
    root@shserver1:~# traceroute xmserver2
    traceroute to xmserver2 (10.125.159.223), 30 hops max, 60 byte packets
    1 10.4.69.2 (10.4.69.2) 0.621 ms 1.180 ms 1.454 ms
    2 * * *
    3 * * *
    princeofwales
        8
    princeofwales  
       2014-07-15 12:03:47 +08:00
    @clino 看配置没发现问题
    10.4.69.8是路由器,10.4.69.2网关有没有配源地址路由?
    网络服务可不可以重启一下,路由表这东西印象中没有缓存的

    traceroute公网IP走哪个出口?
    只有去xmserver1不正常吗,加一条静态路由行不行?若还不行的话我猜是metric的问题
    clino
        9
    clino  
    OP
       2014-07-15 15:49:11 +08:00
    @princeofwales 这好几个问题我还不知道要怎么回答

    "10.4.69.8是路由器,10.4.69.2网关有没有配源地址路由?" 问题看不懂,要问一下IT

    "网络服务可不可以重启一下,路由表这东西印象中没有缓存的" 因为服务一直在跑现在不太敢重启,但你提到了路由缓存,结果我搜了一下是有的: http://blog.csdn.net/dog250/article/details/9139959 "Linux kernel 3.6正式去除了路由cache,原因正如作者所说,它并不适合作为路由表的一部分存在,它是和流量patterns高度相关的,应该作为一种优化在外部实现,比如基于Asic硬卡的转发表中实现,况且,现有的路由cache在大多数情况下并不会带来显著的性能提升"

    我在shserver1 上执行route -C -n ,结果第一条就是和问题相关的,估计这就是问题导致的原因:
    ~# route -C -n
    内核 IP 路由缓存
    Source Destination Gateway Flags Metric Ref Use Iface
    10.4.69.150 10.125.159.218 10.4.69.8 0 0 4 eth2
    10.4.69.210 10.4.69.255 10.4.69.255 ibl 0 0 7 lo

    "traceroute公网IP走哪个出口?"都是内网没有公网
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4470 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 01:06 · PVG 09:06 · LAX 18:06 · JFK 21:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.