|
|
#!/bin/bash
& E/ z; c6 I8 o3 Q####
: o1 e0 t9 S# H! H; C0 y1 P6 }+ WETH=`ip addr |grep eth |grep "state UP" |grep -v eth0 |awk -F ":" '{print $2}'|xargs`
7 |- u0 g# ?4 _" M' twhile [ "$ETH " != "eth0" ]
0 y! J5 m& x! u4 F( B7 zdo
' [! R8 b% w4 _# F+ Q/ l* X9 G& T( C if [ "$ETH" == "eth1" ];then) ~4 u5 P7 O9 O& _5 X3 ~
cat >/etc/sysctl.conf <<EOF2 D- Z, d/ B/ u( r8 ?+ W0 E9 b
# sysctl settings are defined through files in
7 S1 G3 p. X* Q$ l4 B1 a/ s! `2 ]# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.# ^3 U o; ?' N" d4 m$ {2 S; |5 I. x
## F t3 A0 |' o
# Vendors settings live in /usr/lib/sysctl.d/.
7 B- S: Q9 z" \( ]# K, }# To override a whole file, create a new file with the same in* e2 X. v4 J; Q# V7 R) }" N4 c2 F
# /etc/sysctl.d/ and put new settings there. To override
( I8 D. [+ m+ O3 i. v' P, @# only specific settings, add a file with a lexically later
& @+ T/ a4 @& {" b' P4 `# name in /etc/sysctl.d/ and put new settings there.0 M2 r$ C4 |1 p$ [2 h9 Y6 G
#- z$ b# V( f# _+ M
# For more information, see sysctl.conf(5) and sysctl.d(5).
+ W9 k6 }( g$ a" A. m. a8 Dnet.ipv4.conf.all.rp_filter = 06 R: U; i% Y8 p m# K
net.ipv4.conf.eth0.rp_filter = 0
9 c0 J( K# S5 O. H& h; @: fnet.ipv4.conf.$ETH.rp_filter = 0
$ h6 t3 V2 V# Q. {+ H5 f) [: wEOF# w8 C, }/ C3 z3 B7 S- E5 K1 U
else5 g' e3 R% _2 T, R7 n3 Z: o2 Q! ~
cat >/etc/sysctl.conf <<EOF
9 a$ C& A% r8 b7 D& g) f; p! z # sysctl settings are defined through files in+ N& L8 j* |/ f2 f& B) s8 S7 E' D; ?1 u
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
( a, ?0 T/ E* \$ Y#. M* s* J; k2 T7 \& p
# Vendors settings live in /usr/lib/sysctl.d/.5 o9 U* x& ^2 H1 W8 h# ^
# To override a whole file, create a new file with the same in: _) y+ R) K1 L
# /etc/sysctl.d/ and put new settings there. To override
5 d% d7 F$ D! F# only specific settings, add a file with a lexically later
- u$ C' }. e1 Z2 t# name in /etc/sysctl.d/ and put new settings there.; `% W; b, z. a% g( \5 x
#1 N; v- s4 q4 ]5 S6 p8 y# o0 z
# For more information, see sysctl.conf(5) and sysctl.d(5).
+ P' |3 T: G. h" c1 }net.ipv4.conf.all.rp_filter = 08 C R5 Y% c" N B% h
net.ipv4.conf.eth0.rp_filter = 0 ( n' [/ w0 x% }5 @( _
EOF
$ \ s3 _) T2 z1 j6 p% C! d nfi
9 ?9 Q" B3 T4 P" S% u3 l8 ^###kernel on 4 e, h9 \3 Y( A4 Z6 M1 P, `8 L
sysctl -p- X/ j$ m% y8 o
sleep 300- [+ r- v2 X- j) S
done % `8 l1 \: Z# m c5 a) `- l' G3 A' `
exit 06 \6 o6 I% t5 u& F/ o
|
|