#!/bin/bash #useing parameter ip:netmask:gateway:dns1 #system version:centos6,7/redhat6,7 #read parameter ipaddr=`echo $1|cut -d ":" -f 1` netmask=`echo $1|cut -d ":" -f 2` gateway=`echo $1|cut -d ":" -f 3` dns1=`echo $1|cut -d ":" -f 4` dns2=`echo $1|cut -d ":" -f 5` targetDevice=$2 #get device(active) name -- centos6 and centos7 DEVICE=`dmesg|grep Link|grep Up|cut -d ":" -f 3,4|cut -d " " -f 2|cut -d ":" -f 1|uniq|head -n 1` #if parameter has device name,use it ,else use first alive device if [ "$targetDevice" != "" ]; then DEVICE=$targetDevice echo 'device use target device :' $DEVICE fi #backup net_file mv /etc/sysconfig/network-scripts/'ifcfg-'$DEVICE /etc/sysconfig/network-scripts/'ifcfg-'$DEVICE'.bak' -f #config(net_file) cat <<end>> /etc/sysconfig/network-scripts/'ifcfg-'$DEVICE DEVICE=$DEVICE ONBOOT=yes TYPE=Ethernet BOOTPROTO=none IPV6INIT=no DEFROUTE=yes IPADDR=$ipaddr GATEWAY=$gateway NETMASK=$netmask DNS1=$dns1 DNS2=$dns2 end #update /etc/hosts cat /sensor/bin/standardhosts>/etc/hosts echo '127.0.0.1 '$(hostname)>>/etc/hosts #grant the net_file chmod 755 /etc/sysconfig/network-scripts/'ifcfg-'$DEVICE #restart network /etc/init.d/network restart
nm_object_array_demarshal: couldn't create object for /org/freedesktop/NetworkManager/ActiveConnection/39
Error: Obtaining active connection for'/org/freedesktop/NetworkManager/ActiveConnection/39' failed.
[FAILED]
See ‘systemctlstatus network.service‘ and ‘journalctl-xn‘ for details
Bringing up interface enp4s0f0: RTNETLINK answers: File exists
Bringing up interface eth0: Device eth0 does not seem to be present,delaying initialization.
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有