Centos/Linux下如何查看网关地址/Gateway地址

  • Centos/Linux下如何查看网关地址/Gateway地址? Linux下查看网关的命令还是很多的,不过如果IP是DHCP获取,那么有些命令是不适用的,当然也有通用的查询网关命令.

     

    1.ifconfig -a 和 cat /etc/resolv.conf  (主要查看ip/netmask和dns)

    2.netstat -rn

    3.cat /etc/sysconfig/network

    4.cat /etc/sysconfig/network-scripts/ifcfg-eth0

    5.traceroute 第一行就是自己的网关

    6.ip route show

    7.route -n

    以上几个是比较常用的查询网关的命令。下面是范例:

     

    [root@www.ctohome.com]# netstat -rn
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    184.82.152.96   0.0.0.0         255.255.255.248 U         0 0          0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
    0.0.0.0         184.82.152.97   0.0.0.0         UG        0 0          0 eth0

     


    [root@www.ctohome.com]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
    # Intel Corporation 82567V-2 Gigabit Network Connection
    DEVICE=eth0
    BOOTPROTO=none
    HWADDR=00:1c:c0:f8:a1:ac
    ONBOOT=yes
    NETMASK=255.255.255.248
    IPADDR=184.82.152.98
    GATEWAY=184.82.152.97
    TYPE=Ethernet

     


    [root@www.ctohome.com]# ip route show
    184.82.152.96/29 dev eth0  proto kernel  scope link  src 184.82.152.98 
    169.254.0.0/16 dev eth0  scope link 
    default via 184.82.152.97 dev eth0


    [root@www.ctohome.com]# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    184.82.152.96   0.0.0.0         255.255.255.248 U     0      0        0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
    0.0.0.0         184.82.152.97   0.0.0.0         UG    0      0        0 eth0

     

    [root@www.ctohome.com]#  ifconfig -a
    eth0      Link encap:Ethernet  HWaddr 00:1C:C0:F8:A1:AC  
              inet addr:184.82.152.98  Bcast:184.82.152.103  Mask:255.255.255.248

  • 17
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值