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
  • 相关阅读:
    494. Target Sum 添加标点符号求和
    636. Exclusive Time of Functions 进程的执行时间
    714. Best Time to Buy and Sell Stock with Transaction Fee有交易费的买卖股票
    377. Combination Sum IV 返回符合目标和的组数
    325. Maximum Size Subarray Sum Equals k 和等于k的最长子数组
    275. H-Index II 递增排序后的论文引用量
    274. H-Index论文引用量
    RabbitMQ学习之HelloWorld(1)
    java之struts2的数据处理
    java之struts2的action的创建方式
  • 原文地址:https://www.cnblogs.com/firestar277/p/14635782.html
Copyright © 2011-2022 走看看