临时出差任务

目录

临时出差任务

需求

  • 网络重新架构.三层网络
  • 服务器都按标准设置固定的IP,host名称以IP命名
  • 路由器设置好做好映射,看看路由器能设置多少台设备,保证之后添加机器都能映射上

IP配置

bresee@bresee:~$ vim /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    renderer: networkd
    ethernets:
       enp129s0f0:
               dhcp4: no
               dhcp6: no
               addresses: [10.50.12.10/22]
               gateway4: 10.50.12.1
               nameservers:
                       addresses: [10.30.12.6,10.50.0.50]

netplan apply

主机名配置

取出IP来之后,将主机名写入到配置文件当中,重启设备;

 ip addr show eth0 | awk 'NR==3{print $2}' | sed -r 's@(^.*)\/24@\1@' > /etc/hostname 
[root@ZhangHe ~]# ip addr show eth0 | awk 'NR==3{print $2}' | sed -r 's@(^.*)\/24@\1@' | awk -F"/" '{print $1}' | awk -F"." '{print $4}'
83
[root@ZhangHe ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.24.16.83  netmask 255.255.240.0  broadcast 172.24.31.255
        ether 00:16:3e:00:12:ed  txqueuelen 1000  (Ethernet)
        RX packets 8476793  bytes 3428325089 (3.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9101378  bytes 1292103053 (1.2 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 168  bytes 13528 (13.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 168  bytes 13528 (13.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@ZhangHe ~]# ip addr show eth0 | awk 'NR==3{print $2}' | sed -r 's@(^.*)\/24@\1@' | awk -F"/" '{print $1}' | awk -F"." '{print $4}'
83

端口映射ssh号端口

H3C ER32002路由器

测试

自动化脚本

上一篇:jQuery - 链(Chaining)


下一篇:精读《Optional chaining》