Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. function share_net(){
  2.     a(){ echo -e "\n End called with ${@}"; }
  3.     trap 'a args1 args2' INT
  4.     OUT_IF=${2}
  5.     [ "${OUT_IF}x" == "x" ] && OUT_IF=`grep rndis /sys/class/net/*/device/uevent|cut -d'/' -f 5`
  6.     ifconfig ${OUT_IF} down
  7.     ifconfig ${OUT_IF} ${1} netmask 255.255.255.0 up
  8.     GATE_IP=`ip -4 route list 0/0 | cut -d' ' -f 3`
  9.     GATE_IF=`ip -4 route list 0/0 | cut -d' ' -f 5`
  10.     RANGE=`echo ${1}|awk -F '.' '{print $1"."$2"."$3"."$4+1","$1"."$2"."$3"."254}'`
  11.     echo 1 > /proc/sys/net/ipv4/ip_forward
  12.     iptables -t nat -A POSTROUTING -o ${GATE_IF} -j MASQUERADE
  13.     iptables -A FORWARD -i ${OUT_IF} -j ACCEPT
  14.     iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  15.     iptables -t nat -A POSTROUTING -j MASQUERADE
  16.     killall -q -9 dnsmasq
  17.     dnsmasq                    \
  18.     --no-daemon                \
  19.     --domain-needed            \
  20.     --bogus-priv               \
  21.     --local=/localnet/         \
  22.     --cache-size=10000         \
  23.     --interface=${OUT_IF}      \
  24.     --listen-address=127.0.0.1 \
  25.     --dhcp-range=${RANGE},7d   \
  26.     --dhcp-option=3,${GATE_IP} \
  27.     --dhcp-option=42,0.0.0.0   \
  28.     --dhcp-option=19,0         \
  29.     --dhcp-option=44,0.0.0.0   \
  30.     --dhcp-option=45,0.0.0.0   \
  31.     --dhcp-option=46,8         \
  32.     #--dhcp-host=00:03:1d:04:67:f0,workstation,192.168.1.10,infinite
  33.     trap sig_handler 15
  34. }
  35.  
  36. share_net 192.168.0.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement