| 
                         以下附加一份IP配置脚本,因为比较特殊,需要在网卡上配置vlan,打vlan标签。 
- ip.txt    
 - #依次对应序列号、业务网IP、数据网IP、管理网IP、主机名    
 - XXXXXXXX 10.1.1.1 10.10.1.1 10.20.1.1 XXXX-1.1 
 -  
 - ip.sh 
 - SN=`dmidecode -t 1 |grep "Serial Number" |awk -F ": " '{print $2}'` #取本机序列号 
 - ip_1=`cat /tmp/ip.txt |grep $SN |awk -F " " '{print $2}'` #按照序列号指定对应IP   
 - ip_10=`cat /tmp/ip.txt |grep $SN |awk -F " " '{print $3}'` 
 - ip_20=`cat /tmp/ip.txt |grep $SN |awk -F " " '{print $4}'` 
 - host_name=`cat /tmp/ip.txt |grep $SN |awk -F " " '{print $5}'` 
 -  
 - cat > /etc/sysconfig/network-scripts/ifcfg-eth2  << EOF 
 - TYPE=Ethernet 
 - BOOTPROTO=none 
 - DEVICE=eth2 
 - ONBOOT=yes 
 - IPADDR=$ip_10 
 - PREFIX=24 
 - EOF 
 -  
 - cat > /etc/sysconfig/network-scripts/ifcfg-eth3 << EOF 
 - TYPE=Ethernet 
 - BOOTPROTO=none 
 - DEVICE=eth3 
 - ONBOOT=yes 
 - IPADDR=$ip_20 
 - PREFIX=24 
 - EOF 
 -  
 - cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF 
 - DEVICE=eth0 
 - ONBOOT=yes 
 - USERCL=no 
 - MASTER=bond0 
 - SLAVE=yes 
 - EOF 
 -  
 - cat > /etc/sysconfig/network-scripts/ifcfg-eth1 << EOF 
 - DEVICE=eth1 
 - ONBOOT=yes 
 - USERCTL=no 
 - MASTER=bond0 
 - SLAVE=yes 
 - EOF 
 -  
 - #config bond 
 - cat >  /etc/sysconfig/network-scripts/ifcfg-bond0 << EOF   
 - DEVICE=bond0 
 - BOOTPROTO=none 
 - DEFROUTE=yes 
 - IPV4_FAILURE_FATAL=no 
 - NAME=bond0 
 - ONBOOT=yes 
 - IPADDR=$ip_1 
 - PREFIX=24 
 - GATEWAY=10.1.1.254 
 - IPV6_PEERDNS=yes 
 - IPV6_PEERROUTES=yes 
 - BONDING_OPTS="miimon=100 mode=4" 
 - EOF 
 -  
 - cat > /etc/sysconfig/network-scripts/route-eth2 << EOF #为网卡加入路由,使其他网卡能访问别的网段 
 - 10.10.0.0/16 via 10.10.1.254 
 - EOF 
 -  
 - cat > /etc/sysconfig/network-scripts/route-eth3 << EOF 
 - 10.20.0.0/16 via 10.20.1.254 
 - EOF 
 -  
 - systemctl restart network 
 -  
 - echo "$host_name" > /etc/hostname 
 -  
 - echo "$ip_1 $host_name" >> /etc/hosts 
 
                          (编辑:晋中站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |