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 重启网卡
  • 相关阅读:
    正则表达式
    什么是面向对象
    关于jdk,jre,jvm和eclipse的一些总结
    分析ajax爬取今日头条街拍美图
    pycharm误删恢复方法及python扩展包下载地址
    django 之 视图层、模板层
    django
    django框架基础二
    jdango框架基础一
    安装软件,提高速度,可以使用清华源
  • 原文地址:https://www.cnblogs.com/zxaben/p/14874281.html
Copyright © 2011-2022 走看看