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