Лс
Size: a a a
Лс
EP
S
U
U
Лс
AN
S
ip route add 10.42.0.0/24 dev eth0 table 10
ip route add 10.42.0.0/24 dev eth1 table 11
ip rule add from 10.42.0.0/24 oif eth0 table 10 pref 1000
ip rule add from 10.42.0.0/24 oif eth1 table 11 pref 1001
S
AN
SG
A
S
S
A
A
S
IPTABLES=/sbin/iptables
function enable () {
NAMETABLE='eth0_to_eth1'
# enable ip forwarding in the kernel
echo 'Enabling Kernel IP forwarding...'
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward
# flush rules and delete chains
echo 'Flushing rules and deleting existing chains...'
$IPTABLES -F
$IPTABLES -X
# enable masquerading to allow LAN internet access
echo 'Enabling IP Masquerading and other rules...'
$IPTABLES -t nat -A POSTROUTING -o $LANIF -j MASQUERADE
$IPTABLES -A FORWARD -i $LANIF -o $WANIF -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $WANIF -o $LANIF -j ACCEPT
ip route add default via 10.42.0.2 table $NAMETABLE
ip rule add iif $LANIF table $NAMETABLE
echo 'Done.'
}
WANIF='eth1'
LANIF='eth0'
enable
A
S
A