23:LVS客户端配置脚本案例

[root@web03 scripts]# cat prevent_arp.sh 
#!/bin/bash

lo_ip=$(ip a s lo|grep "10.0.0.1[3]/32"|wc -l)

if [ $lo_ip -eq 0 ]
then
    ip addr add 10.0.0.13/32 dev lo
fi

ip_cnf=$(egrep "net.ipv4.conf" /etc/sysctl.conf|wc -l)

if [ $ip_cnf -lt 4 ]
then
    
    cat >>/etc/sysctl.conf<<-EOF
    net.ipv4.conf.all.arp_ignore = 1
    net.ipv4.conf.all.arp_announce = 2
    net.ipv4.conf.lo.arp_ignore = 1
    net.ipv4.conf.lo.arp_announce = 2
    EOF


    sysctl -p
fi

 

posted @ 2017-12-08 21:59  滴滴滴  阅读(316)  评论(0编辑  收藏  举报