Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "Activation du routage"
- echo 1 > /proc/sys/net/ipv4/ip_forward
- # -t indicates which interfaces we use
- #here when there a new packet connection, "mangle" applies
- #-F delete all the rules in the "mangle" table
- iptables -t mangle --flush
- echo "previous rules for mangle table have been deleted"
- #all the counters to 0
- iptables --zero
- echo "counters to 0"
- echo "Which interface ?"
- read int
- #--tee Make a copy of the packet, and route that copy to the given destination. For the original, uncopied packet, behave like a non-terminating target and continue traversing the rules.
- #--gw IP_address Route the packet via this gateway
- iptables -t mangle -A PREROUTING -i $int -j ROUTE -tee --gw 192.168.1.250
- #FORWARD : The FORWARD policy allows an administrator to control where packets can be routed within a LAN.
- #for the default "filter" table, add rule (-A) to the FORWARD chain by autorizing traffic action, -j ACCEPT.
- iptables -A FORWARD --in-interface $int -j ACCEPT
- echo "Forwarding packets to $int"
- #MASQUERADE: modify packet in order to hide some informations about his origin
- #for 'mangle' table, add rule for routing modified packet by an interface.
- iptables -t mangle -A POSTROUTING --out-interface $int -j MASQUERADE
- echo "postrouting packets by $int are falsified"
- # Forward to the gateway
- echo "redirection faite"
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement