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
  • 相关阅读:
    程序员最好也要懂的一些沟通说服技巧
    MapFields和并行计算(OpenFOAM)
    Python 调用自己编写的Class
    Ubuntu 图形桌面死机重启(机器不重启)
    Ubuntu 安装 Visual Studio Code
    Ubuntu图形界面和终端界面切换快捷键
    Linux直接在通过终端打开图片文件
    Linux新建环境变量快速切换到文件夹(export)
    Python文件读写(一)
    Dictonary(Python)(一)
  • 原文地址:https://www.cnblogs.com/firestar277/p/14635782.html
Copyright © 2011-2022 走看看