zoukankan      html  css  js  c++  java
  • 命令行下设置IP地址的方法

    在Linux Shell 中设置IP地址的地址的方法很多,我比较喜欢到 /etc/sysconfig/network-script/ 中修改各个 eth* 的文件,然后再重启网络使之生效。

    Windows 中设置IP地址,估计大部分人都只知道到 “网络连接”,然后在对应的网络连接中修改IP地址。

    image

    这个窗口大家一定非常熟悉了吧。

    但是,命令行中如何设置IP地址呢,这个就是本文主要阐述的主要内容了。

    首先建立环境吧,将本机IP设置为如上图所示的IP地址。

    然后在命令行中 :

    C:\>ipconfig
    Windows IP Configuration
    
    Ethernet adapter 本地连接:
    
            Connection-specific DNS Suffix  . :
            IP Address. . . . . . . . . . . . : 192.168.5.35
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.5.1
    
    C:\>ping 192.168.5.35
    Pinging 192.168.5.35 with 32 bytes of data:
    
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    
    Ping statistics for 192.168.5.35:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\>ping 192.168.5.36
    Pinging 192.168.5.36 with 32 bytes of data:
    
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    
    Ping statistics for 192.168.5.36:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

    输入这几个名定目的是
    1。检查网络的配置情况
    2。寻找一个空闲的IP地址,本例中的空闲IP地址是 192.168.5.36

    按照以下几个步骤走:

    一 修改IP地址为

    用命令行修改以下几个信息:

    IP   :192.168.5.36

    掩码:255.255.255.0

    网关:192.168.5.1

    对应的命令是:

    netsh interface ip set address "本地连接" static 192.168.5.36 255.255.255.0 192.168.5.1 auto

    二 绑定多一个IP地址

    什么?!,你不知道一块网卡可以绑定多个地址

    netsh interface ip add address "本地连接" 192.168.5.36 255.255.255.0 

    验证一下配置

    C:\>ipconfig
    Windows IP Configuration
    
    Ethernet adapter 本地连接:
    
            Connection-specific DNS Suffix  . :
            IP Address. . . . . . . . . . . . : 192.168.5.36
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            IP Address. . . . . . . . . . . . : 192.168.5.35
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.5.1
    
    C:\>ping 192.168.5.35
    Pinging 192.168.5.35 with 32 bytes of data:
    
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.35: bytes=32 time<1ms TTL=128
    
    Ping statistics for 192.168.5.35:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\>ping 192.168.5.36
    Pinging 192.168.5.36 with 32 bytes of data:
    
    Reply from 192.168.5.36: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.36: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.36: bytes=32 time<1ms TTL=128
    Reply from 192.168.5.36: bytes=32 time<1ms TTL=128
    
    Ping statistics for 192.168.5.36:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    

    三 删除一个IP地址

    既然可以绑定多个IP地址,当然也是可以删除的
    netsh interface ip delete address "本地连接" 10.168.5.36
    


    使用命令行添加、删除、修改IP地址的介绍就到这里了,希望对你有帮助。
  • 相关阅读:
    初级模拟电路:8-1 运算放大器概述
    初级模拟电路:6-1 FET概述
    初级模拟电路:5-5 甲乙类功率放大器
    初级模拟电路:5-4 乙类功率放大器
    初级模拟电路:5-3 变压器耦合型甲类功放
    初级模拟电路:5-2 串馈型甲类功放
    μC/OS-II系统中事件标志的使用
    STM32-SPI读写外部FLASH(W25Q64)
    STM32-定时器输出比较模式输出方波(DMA方式)
    STM32-定时器输出比较模式输出方波(中断方式)
  • 原文地址:https://www.cnblogs.com/killkill/p/1433704.html
Copyright © 2011-2022 走看看