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
  • 相关阅读:
    LeetCode 326. Power of Three
    LeetCode 324. Wiggle Sort II
    LeetCode 322. Coin Change
    LeetCode 321. Create Maximum Number
    LeetCode 319. Bulb Switcher
    LeetCode 318. Maximum Product of Word Lengths
    LeetCode 310. Minimum Height Trees (DFS)
    个人站点大开发!--起始篇
    LeetCode 313. Super Ugly Number
    LeetCode 309. Best Time to Buy and Sell Stock with Cooldown (DP)
  • 原文地址:https://www.cnblogs.com/firestar277/p/14635782.html
Copyright © 2011-2022 走看看