Linux shell 命令 -- route, ifconfig

[Copy from http://www.cnblogs.com/mydomain/archive/2011/09/29/2195699.html]


3、route

1)route [-nee]

route add [-net|-host] [网域或主机] netmask [mask] [gw|dev]

route del [-net|-host] [网域或主机] netmask [mask] [gw|dev]

2)option

-n:不使用协议或主机名称,直接使用IP或port number

-ee:使用更详细的信息来显示

增加(add) 与删除 (del) 路由的相关参数:

-net:表示后面接的路由为一个网域;

-host:表示后面接的为连接到单部主机的路由;

netmask:子网掩码

gw:gateway 的简写;

dev指定由那一块网卡连线出去,后面接 eth0

关于结果中Flags的说明,见【1】。

3) 示例

1)route del -net 169.254.0.0 netmask 255.255.0.0 dev eth0 //路由表中各项要写全

2)route add -net 192.168.100.0 netmask 255.255.255.0 dev eth0

3)route add default gw 192.168.1.250

/etc/init.d/network restart //刚刚的设定全部失效,以ifcfg-ethX 的设定为主

default = 0.0.0.0/0.0.0.0

4、ifconfig,ifup,ifdown

1) 说明

ifconfig {interface} {up|down}

ifconfig interface address {options}

    可以设置虚拟网络接口:指的是为一个网络接口指定多个IP地址,虚拟接口是这样的 eth0:0 、 eth0:1、eth0:2 ... .. eth1N。比如,我们可以用不同的IP地址来架运行多个httpd服务器。

2)option

interface:网卡号,包括eth0, eth1, ppp0

options::

up, down:启动 (up) 或关闭 (down) 该网络界面(不涉及任何参数)

mtu:可以设定不同的 MTU 数值,例如 mtu 1500 (单位为byte)

netmask:子网掩码

broadcast:广播位址

3)示例

ifconfig eth0 192.168.100.100 //设置eth0的ip

ifconfig eth0 192.168.100.100 netmask 255.255.255.128 mtu 8000

ifconfig eth0:0 192.168.50.50 // eth0:0,在该实体网卡上,再模拟一个网络地址,亦即是在一张网络卡上面设定多个IP

ifconfig eth0:0 down

/etc/init.d/network restart //刚刚的设定全部失效,会以ifcfg-ethX的设定为主

/etc/sysconfig/network/config

ifconfig eth1:0 192.168.1.250 hw ether 00:11:00:00:11:44 netmask 255.255.255.0 broadcast 192.168.1.255 up //hw后面是网络接口类型,ether表示以太网

4)ifup,ifdown是两个脚本,会直接到 /etc/sysconfig/network-scripts 目录下搜寻对应的设定档,通过其相应的脚本来启动关闭。

ifup | ifdown  {interface}

5、ip命令【1

参考

1】 对命令进行了一些讲解

http://linux.vbird.org/linux_server/0140networkcommand.php#netstat

2】 对tcp的state讲解的较好,如TIME_WAIT:The socket is waiting after close to handle packets still in the network.

http://linux.die.net/man/8/netstat

3】http://www.linuxso.com/command/netstat.html

4】 traceroute的用法示例

http://blog.sina.com.cn/s/blog_4895289e010009bn.html

对来龙去脉讲的好

http://blog.chinaunix.net/space.php?uid=20172731&do=blog&cuid=159630

5】ifconfig用法

http://www.cublog.cn/u2/78880/showart_1879201.html


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值