传统网络配置命令与IP高级路由命令 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    导读:首先,先了解传统的网络配置命令: 1. 使用ifconfig命令配置并查看网络接口情况 示例1: 配置eth0的IP,同时激活设备: # ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up 示例2: 配置eth0别名设备 eth0:1 的IP,并添加路由 # ifconfig eth0:1 192.168.4.2 # route add –host 192.168.4.2 dev eth0:1 示例3:激活(禁用)设备...

正文:

    懂得网络配置命令是一般技术人员必备的技术,经过一段时间的研究和学习,总结了一些常用的命令和示例以便日后查阅.

    传统的在1--3点,ip高级路由命令在4--12点,两者部分可以通用,并达到同样的目的,但ip的功能更强大,可以实现更多的配置目的,

传统网络配置命令与IP高级路由命令

    首先,先了解传统的网络配置命令:

    1. 使用ifconfig命令配置并查看网络接口情况

    示例1: 配置eth0的IP,同时激活设备:

    # ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up

    示例2: 配置eth0别名设备 eth0:1 的IP,并添加路由

    # ifconfig eth0:1 192.168.4.2

    # route add –host 192.168.4.2 dev eth0:1

    示例3:激活(禁用)设备

    # ifconfig eth0:1 up(down)

    示例4:查看所有(指定)网络接口配置

    # ifconfig (eth0)

    2. 使用route 命令配置路由表

    示例1:添加到主机路由

    # route add –host 192.168.4.2 dev eth0:1

    # route add –host 192.168.4.1 gw 192.168.4.250

    示例2:添加到网络的路由

    # route add –net IP netmask MASK eth0

    # route add –net IP netmask MASK gw IP

    # route add –net IP/24 eth1

    示例3:添加默认网关

    # route add default gw IP

    示例4:删除路由

    # route del –host 192.168.4.1 dev eth0:1

    示例5:查看路由信息

    # route 或 route -n (-n 表示不解析名字,列出速度会比route 快)

    3.ARP 管理命令

    示例1:查看ARP缓存

    # arp

    示例2: 添加

    # arp –s IP MAC

    示例3: 删除

    # arp –d IP

    4. ip是iproute2软件包里面的一个强大的网络配置工具,它能够替代一些传统的网络管理工具,

电脑资料

传统网络配置命令与IP高级路由命令》(https://www.unjs.com)。

    例如:ifconfig、route等,

    上面的示例完全可以用下面的ip命令实现,而且ip命令可以实现更多的功能.下面介绍一些示例:

    4.0 ip命令的语法

    ip [OPTIONS] OBJECT [COMMAND [ARGUMENTS]]

    4.1 ip link set--改变设备的属性. 缩写:set、s

    示例1:up/down 起动/关闭设备。

    # ip link set dev eth0 up

    这个等于传统的 # ifconfig eth0 up(down)

    示例2:改变设备传输队列的长度。

    参数:txqueuelen NUMBER或者txqlen NUMBER

    # ip link set dev eth0 txqueuelen 100

    示例3:改变网络设备MTU(最大传输单元)的值。

    # ip link set dev eth0 mtu 1500

    示例4: 修改网络设备的MAC地址。

    参数: address LLADDRESS

    # ip link set dev eth0 address 00:01:4f:00:15:f1

    4.2 ip link show--显示设备属性. 缩写:show、list、lst、sh、ls、l

    -s选项出现两次或者更多次,ip会输出更为详细的错误信息统计。

    示例:

   

<ccid_code /># ip -s -s link ls eth0        eth0:  mtu 1500 qdisc cbq qlen 100     link/ether 00:a0:cc:66:18:78 brd ff:ff:ff:ff:ff:ff     RX: bytes  packets  errors  dropped overrun mcast     2449949362 2786187 0 0 0 0     RX errors: length crc frame. fifo missed        0 0 0 0 0     TX: bytes  packets errors dropped carrier collsns     178558497  1783946 332 0 332 35172     TX errors: aborted fifo window heartbeat        0 0 0 332     这个命令等于传统的 ifconfig eth0</ccid_code />

最新文章