zoukankan      html  css  js  c++  java
  • Linux学习

    为什么需要修改

    因为需要用来做k8s集群,通过克隆出来的虚拟机需要修改Host Name 以及 静态IP。

    操作(Debian10)

    修改 Host

    1. 使用命令 hostnamectl 查看当前系统主机名;
    2. 使用命令 hostnamectl set-hostname 新名 设置新主机名;
    3. 打开 /etc/hosts 文件并用新的主机名替换旧的主机名。
    $ nano /etc/hosts
    
    127.0.0.1  localhost
    127.0.0.1  新名
    
    # The following lines are desirable for IPv6 capable hosts
    ::1    localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    

    修改 静态IP

    • 1.使用命令 ip a 查看当前网卡设备名以及IP
    • 2.打开 /etc/network/interfaces 文件并用修改IP。
    
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    # allow-hotplug ens192 # 设置成这个不知道为什么系统不会自动开启网口
    auto ens192
    iface ens192 inet static
            address 1.1.1.2/24
            gateway 1.1.1.1
            # dns-* options are implemented by the resolvconf package, if installed
            dns-nameservers 8.8.8.8 8.8.4.4 202.96.128.86
    
    

    网卡参数配置语法:

    auto ${网卡名}
    iface ${网卡名} inet ${static}
    address ${IP}
    netmask ${netmask}
    gateway ${gateway}
    

    allow-hotplug 与 auto 的区别:
    auto: 在系统启动的时候启动网络接口,无论网络接口有无连接 (插入网线)。如果该接口配置了 DHCP,则无论有无网线,系统都会去获取 DHCP。并且如果没有插入网线,则等该接口超时后才会继续 DHCP。
    allow-hotplug: 只有当内核从网络接口检测到热插拔事件后才会启动该接口。如果系统开机时该接口没有插入网线,则系统不会启动该接口。系统启动后,如果插入网线,系统会自动启动该接口。

    • 3.使用命令 systemctl restart networking 重启网卡
  • 相关阅读:
    【路由介绍】
    asp.net MVC 中枚举创建下拉列表?
    DELPHI中的快捷方式一览(完全版)
    C#连接mysql实例
    编写测试类,了解ArrayList的方法
    C# 验证IP是否正确简易方法 源代码
    C# 多线程操作样例
    C# 乘法口诀表的实现方法
    C# 调用系统API 内核 简单样例
    C# 基础 计算平均值的方法
  • 原文地址:https://www.cnblogs.com/zxaben/p/14874281.html
Copyright © 2011-2022 走看看