Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.37 KB | None | 0 0
  1. #!/bin/bash
  2.        
  3.  
  4. echo "Activation du routage"
  5. echo 1 > /proc/sys/net/ipv4/ip_forward
  6.  
  7.  
  8. # -t indicates which interfaces we use
  9. #here when there a new packet connection, "mangle" applies
  10. #-F delete all the rules in the "mangle" table
  11. iptables -t mangle --flush
  12. echo "previous rules for mangle table have been deleted"
  13.  
  14. #all the counters to 0
  15. iptables --zero
  16. echo "counters to 0"
  17.  
  18. echo "Which interface ?"
  19. read int
  20.  
  21. #--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.
  22. #--gw IP_address Route the packet via this gateway
  23. iptables -t mangle -A PREROUTING -i $int -j ROUTE -tee --gw 192.168.1.250
  24.  
  25. #FORWARD : The FORWARD policy allows an administrator to control where packets can be routed within a LAN.
  26. #for the default "filter" table, add rule (-A) to the FORWARD chain by autorizing traffic action, -j ACCEPT.
  27. iptables -A FORWARD --in-interface $int -j ACCEPT
  28. echo "Forwarding packets to $int"
  29.  
  30. #MASQUERADE: modify packet in order to hide some informations about his origin
  31. #for 'mangle' table, add rule for routing modified packet by an interface.
  32. iptables -t mangle -A POSTROUTING --out-interface $int -j MASQUERADE
  33. echo "postrouting packets by $int are falsified"
  34.  
  35. # Forward to the gateway
  36.  
  37. echo "redirection faite"
  38.  
  39. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement