zoukankan      html  css  js  c++  java
  • linux网络命令详解

    1 ifconfig命令

    格式:ifconfig  {inerface} {options}

    options参数有:up,down,mtu,netmask,broadcast

    单独ifconfig命令:查看网络所有端口;

    范例1:ifconfig eth0 192.168.1.0 netmask 255.255.0.0 mtu 8000(配置端口eth0的ip地址)

    范例2:ifconfig eth0:0 192.168.50.50(表示在eth0再仿真出来一个网络接口)

    注意:ifconfig 的配置只会暂时生效,机器重启或者/etc/init.d/network restart ,则会使ifconfig的配置无效;

    2 ifup ifdown命令

    格式:ifup interface ; ifdown interface

    例如:ifup eth0;ifdown eth0

    其实这两个命令是脚本 ,它们是去读取/etc/sysconfig/network-scripts/ifcfg-eth*文件;

    3 route命令

    格式:route或者route -n看路由信息

    route add [-host 或者-net]  netmask  gw或者dev 

    route del  [-host 或者-net]  netmask  gw或者dev

    例子:route add -net 192.168.100.0 netmask 255.255.255.0  dev eth0

    例子:route add default gw 192.168.1.250

    注意:ifconfig eth0 192.168.1.0还是route add -net 192.168.1.0 mask 255.255.255.0 dev eth0 都是临时生效,用来联网和测试,等到测试完毕后,在使         用/etc/init.d/network restart 恢复原来默认网络即可;

    4 ip命令比较强大

    (ip link设定)

    格式:ip link set [device ] [动作和参数]

    例子:ip link show (单纯的看设备的相关硬件信息)

    例子:ip link show eth0

    例子:ip link set  eth0 up ; ip link set eth0 down; ip link set eth0 mtu 1000(打开和关闭端口以及设备mtu)

    例子:ip link set eth0 down> ip link set eth0 name vbird >ip link show(更改eth0的名字,改之前先网卡eth0)

    (ip address)

    格式:ip address [add|del]  [ip]  [dev]   [相关参数]

    例子:ip address show (eth*)

    例子:ip address add 192.168.50.50/24 broadcast dev eth0  label eth0:vbird( 添加一个网络接口)

    例子:ip address del  192.168.50.50/24  dev eth0

    (ip route)

    例子:ip route show 

    例子:ip route add 192.168.5.0/24  dev eth0(添加路由,主要是本机直接可沟通的网络)

    例子:ip route add 192.168.10.0/24  via 192.168.5.100 dev eth0 (添加可以通往外部的路由,需通过router)

    例子:ip route add default  via 192.168.1.254 dev eth0 (添加路由,通过192.168.1.254这台主机通信,事实上这台主机就是我的默认路由器(gateway))

    例子:ip route del 192.168.5.0/24;ip route del 192.168.10.0/24 (删除路由)

    无线网络命令:iwlist(无线网卡进行无线网络的AP的检测与取得相关数据) iwconfig(无线网卡的配置)

    DHCP客户端命令:dhclient  如:dhclient eth0

  • 相关阅读:
    解题报告 百进制数
    解题报告 Loongint 的夜晚
    解题报告 树形图计数
    解题报告 一元三次方程求解
    解题报告 Loongint 的旅行安排
    解题报告 数字查找
    用C++编写简单绘图语言的词法分析器——程序清单
    C++ 连接 mysql 的一个例子(Visual Studio 2005)
    fedora 8 下JDK 6.0 配置
    IBM DB2 V9 常用命令
  • 原文地址:https://www.cnblogs.com/wangnengwu/p/5676725.html
Copyright © 2011-2022 走看看