|
|
#!/bin/bash4 Y+ }" O4 O% g2 ~0 i; z: s
####6 s( D* V# Y1 y! O9 h; y. h
ETH=`ip addr |grep eth |grep "state UP" |grep -v eth0 |awk -F ":" '{print $2}'|xargs`
D( G& y% ~7 g* g; Dwhile [ "$ETH " != "eth0" ]
7 J: E5 \; b! M5 l. g. }do
9 g4 [ q8 x' x4 T if [ "$ETH" == "eth1" ];then
) O6 p2 |# ?2 O; v0 L5 l cat >/etc/sysctl.conf <<EOF2 `: b2 O2 T" b) S. F
# sysctl settings are defined through files in# L" ~6 g4 ^. ~, ^. o1 u T# H% B
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
9 z3 r& g8 U" {$ C) K+ k#0 c& C- L/ c7 w" e' k Y! s& F
# Vendors settings live in /usr/lib/sysctl.d/.
. i4 V8 d Z" M7 B6 G6 J" D4 x# To override a whole file, create a new file with the same in
4 {0 C' w% E' Z9 p2 b: x# /etc/sysctl.d/ and put new settings there. To override
8 H1 z8 v) A9 O2 d9 M$ k# only specific settings, add a file with a lexically later
8 A4 h9 v- m% n! ~# name in /etc/sysctl.d/ and put new settings there.6 h$ k5 W5 o( I( L/ P- E
#
0 L5 w+ x8 g! W$ V# For more information, see sysctl.conf(5) and sysctl.d(5).
6 K- G4 a+ ]- fnet.ipv4.conf.all.rp_filter = 0, P; ~6 T1 I x- D1 d; c
net.ipv4.conf.eth0.rp_filter = 0 2 G- I" K) Z* K X- \, f' ]
net.ipv4.conf.$ETH.rp_filter = 0
* I( k% g7 |# E0 bEOF* U" H+ ~7 M- j: \/ N$ Y
else
% F* ~0 c6 X5 G8 E cat >/etc/sysctl.conf <<EOF
. b. u% T* L$ {$ \; e2 j # sysctl settings are defined through files in
" r" q& \2 y* G. _8 [: k& ^' J# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
C3 n, Z0 @' a% |. A#* m$ t1 y) a& y$ z8 R d
# Vendors settings live in /usr/lib/sysctl.d/.
6 w( v' j/ w# e" {7 o# To override a whole file, create a new file with the same in
' U. m1 M& Y# j* i# /etc/sysctl.d/ and put new settings there. To override
6 x$ l# Q. I. M# e) `# only specific settings, add a file with a lexically later
4 N9 `; N, n+ A! O; a# @) ]# name in /etc/sysctl.d/ and put new settings there.
- S; y X; ?- \* }( A, J#4 A7 Y" d0 z6 n8 ~* j v" A# n
# For more information, see sysctl.conf(5) and sysctl.d(5).
: P. n0 t4 E1 w5 ^+ V& `net.ipv4.conf.all.rp_filter = 01 f; v8 L$ i' U; M( ?" S
net.ipv4.conf.eth0.rp_filter = 0
2 w n! A- Y/ P8 ?; b: {, zEOF
0 U" w9 f( v5 `fi
7 n5 ?& C4 G; C4 u###kernel on
! ^" g% K3 u, d# a. rsysctl -p2 b0 u. g8 K- o0 c$ K/ v
sleep 300
* \8 |* V* I# ~' Rdone
( {" Z6 x5 q8 g# z k. jexit 0
1 N4 C' R D* V/ m a% U% n |
|