• linux快速配置网络脚本


    #!/bin/bash
    echo -e "e[1;32;41m 您是否要使用DHCP,默认使用statice[0m"
    read DHCP
    echo "请输入您要设定的IP地址"
    read IP
    echo "请输入您要使用的DNS地址"
    read DNS
    echo "请输入您的网关"
    read GATEWAY
    echo "请输入您的子网掩码"
    read NETMASK
    function network_settings(){
        echo "TYPE=Ethernet" > /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "BOOTPROTO="$A"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "DEFROUTE="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "PEERDNS="yes"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "PEERROUTES="yes"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV4_FAILURE_FATAL="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV6INIT="yes"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV6_AUTOCONF="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV6_DEFROUTE="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV6_PEERDNS="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV6_PEERROUTES="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPV6_FAILURE_FATAL="no"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "NAME="ens33"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "UUID="0e6ca219-0d2e-4000-8f17-bf7424e46595"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "DEVICE="ens33"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "ONBOOT="yes"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "IPADDR="$IP"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "GATEWAY="$GATEWAY"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "NETMASK="$NETMASK"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    	echo "DNS="$DNS"" >> /etc/sysconfig/network-scripts/ifcfg-ens33
    }
     if [ "$DHCP"  = "DHCP" ];then
                      A="dhcp"
    				  
              else
                      A="static"
              fi
    
    network_settings
    
    echo "nameserver "$DNS"" >>/etc/resolv.conf
    
    systemctl restart network
    
    echo "设置成功"
    

  • 相关阅读:
    一份简单的自我评述
    从诞总那儿得到的一些感悟
    2021秋软件工项目选题
    LeNet 网络进行猫狗大战
    不平行的直线
    切长条
    纪念品分组
    奇♂妙拆分
    Qt 一些日期格式转换不精确
    windbg 查看崩溃日志
  • 原文地址:https://www.cnblogs.com/hxlinux/p/13630086.html
Copyright © 2020-2023  润新知