linux ipconfig和route 命令



使用ifconfig命令

语法格式:

ifconfig :不加任何选项表示只显示接口为up状态的接口信息

Ifconfig -a:表示显示所有接口的接口信息,不管该接口是up还是down都显示


Ifconfig interface [ip/netmask] [up|down]表示为该接口配置ip和掩码,并启动或关闭该接口

例子:ifconfig eth0:20 192.10.1.12 netmask 255.255.255.0 up


使用route命令

[root@linux ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.10.0    0.0.0.0         255.255.255.0   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         192.168.10.30   0.0.0.0         UG    0      0        0 eth0

Flags:总共有多个旗标,代表的意义如下:                        

 U (route is up):该路由是启动的;                       

 H (target is a host):目标是一部主机 (IP) 而非网域;                       

 G (use gateway):需要透过外部的主机 (gateway) 来转递封包;                       

 R (reinstate route for dynamic routing):使用动态路由时,恢复路由资讯的旗标;                       

 D (dynamically installed by daemon or redirect):已经由服务或转 port 功能设定为动态路由                       

 M (modified from routing daemon or redirect):路由已经被修改了;                       

 !  (reject route):这个路由将不会被接受(用来抵挡不安全的网域!)

 A (installed by addrconf)

route add default gw 192.168.10.30
增加预设路由的方法!请注意,只有一个预设路由

route add -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41

#添加10.20.30.48的网络

route del -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
#删除路由

route del -net 224.0.0.0 netmask 240.0.0.0 reject

# 目的地址为 224.x.x.x 将被拒绝



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值