以centos7.5为例
1.修改主机名
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname k8s-node1 ##临时生效
localhost.localdomain
[root@localhost ~]# hostnamectl set-hostname k8s-node1 ##重启后永久生效
[root@localhost ~]# reboot
重启后
Last login: Tue Apr ::
[root@k8s-node1 ~]# hostname
k8s-node1
[root@k8s-node1 ~]# cat /etc/hostname
k8s-node1
[root@k8s-node1 ~]# hostnamectl
Static hostname: k8s-node1
Icon name: computer-vm
Chassis: vm
Machine ID: a5a43f5916c643bf83d6f99425a4b9d2
Boot ID: 0043950ecb374652aebb84e6b8f05fa6
Virtualization: vmware
Operating System: CentOS Linux (Core)
CPE OS Name: cpe:/o:centos:centos:
Kernel: Linux 3.10.-.el7.x86_64
Architecture: x86-
[root@k8s-node1 ~]#
修改ip
[root@k8s-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=bf3736be---a658-39d7482dfabd
DEVICE=ens33
#ONBOOT=no ONBOOT=yes
DNS1=192.168.48.2
IPADDR=192.168.48.131
PREFIX=
GATEWAY=192.168.48.2
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
[root@k8s-node1 ~]#
[root@k8s-node1 ~]#
[root@k8s-node1 ~]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@k8s-node1 ~]#
3.centos8重启网络
nmcli c reload
nmcli c up ens33
ifconfig
[root@localhost network-scripts]# ifconfig
ens33: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.48.136 netmask 255.255.255.0 broadcast 192.168.48.255
inet6 fe80:::624d:7d8a:a50a prefixlen scopeid 0x20<link>
ether :0c::::7c txqueuelen (Ethernet)
RX packets bytes (45.9 KiB)
RX errors dropped overruns frame
TX packets bytes (14.9 KiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (14.5 KiB)
RX errors dropped overruns frame
TX packets bytes (14.5 KiB)
TX errors dropped overruns carrier collisions virbr0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether ::::: txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions [root@localhost network-scripts]#
4.虚拟机网络配置
注意ip和网关要在同一网段
5.验证