其他分享
首页 > 其他分享> > 临时出差任务

临时出差任务

作者:互联网

目录

临时出差任务

需求

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路由器

测试

自动化脚本

标签:出差,临时,IP,RX,overruns,bytes,任务,awk,print
来源: https://www.cnblogs.com/yizhangheka/p/14968089.html