zoukankan      html  css  js  c++  java
  • Linux

    配置静态IP

    1.查看IP配置信息

    ifconfig

    如上图所示,我的em1网卡已配置好

    2、编辑em1对应的配置文件,位于/etc/sysconfig/network-scripts/ifcfg-你的网卡名字

    操作:vim /etc/sysconfig/network-scripts/ifcfg-你的网卡名字,按i键进入编辑。编辑结束后Esc退出编辑→Shift+q→!wq→x

    修改配置文件如下图

     参数说明:

    复制代码
    BOOTPROTO="static" # 使用静态IP地址,默认为dhcp 
    IPADDR="19.37.33.66" # 设置的静态IP地址 NETMASK="255.255.255.0" # 子网掩码 GATEWAY="19.37.33.1" # 网关地址 DNS1="192.168.241.2" # DNS服务器(此设置没有用到,所以我的里面没有添加) ONBOOT=yes #设置网卡启动方式为 开机启动 并且可以通过系统服务管理器 systemctl 控制网卡
    复制代码

    3、修改/etc/sysconfig/network

    # Created by anaconda
    NETWORKING=yes
    GATEWAY=19.37.33.1

    4、重启网络服务

    service network restart

    Best commands in my opinion:

    They disables network manager off and on. It is an exact equivalent of unchecking enable networking, and re-checking it to regain connectivity.-

    nmcli networking off hitenter

    enter image description here

    nmcli networking on hit enter

    enter image description here

    Hope this helps.

    I'd use the nmcli commands for that purpose:

    nmcli nm enable false && nmcli nm enable true
    man page:
    
    DESCRIPTION
           nmcli is a command‐line tool for controlling NetworkManager and report‐
           ing on its status.  It is not meant as a full replacement for nm‐applet
           or other similar clients but as a complementary utility to those pro‐
           grams.  The main usage for nmcli is on servers, headless machines or
           for power users who prefer the command line.
    
           [...]
    
      nm     NetworkManager
              Use this object to inquire and change state of NetworkManager.
    
             [...]
    
              enable [true|false]
                     Get networking‐enabled status or enable/disable network‐
                     ing by NetworkManager.  All interfaces managed by Net‐
                     workManager are deactivated when networking has been dis‐
                     abled.
                     Reference to D‐Bus:
                     interface: org.freedesktop.NetworkManager
                     method:    Enable
                     arguments: TRUE or FALSE
  • 相关阅读:
    51nod 最长公共子序列Lcs
    输入挂
    HDU 圆桌会议
    畅通工程
    异形卵
    Python中的多态如何理解?(转帖,让我很理解。)【外加自我看法】(这次修改后应该就是标准答案了)
    Python短路逻辑or的巧妙使用。
    Python三元表达式
    稍微记号下Python的赋值技巧。
    刚看到一个字符串的替换命令,makeslate,记号一下(用处大?应该不算)!
  • 原文地址:https://www.cnblogs.com/firestar277/p/14635782.html
Copyright © 2011-2022 走看看