-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstartConnectifyLinux
More file actions
executable file
·64 lines (52 loc) · 1.37 KB
/
Copy pathstartConnectifyLinux
File metadata and controls
executable file
·64 lines (52 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
FROM_IF=$1
TO_IF=$2
if [ "$FROM_IF" == "" ]
then
FROM_IF="eth0"
fi
if [ "$TO_IF" == "" ]
then
TO_IF="wlan0"
fi
if [ $(whoami) != "root" ];
then
echo "You need to be a root user in order to execute this command.";
echo "Command Usage : sudo connectify <from interface> <to interface>";
exit 1;
elif [ $FROM_IF == $TO_IF ];
then
echo "Both the interfaces selected are same."
echo "Command Usage : sudo connectify <from interface> <to interface>"
exit 1;
fi
echo "Starting the WiFi ..... ";
nmcli nm wifi off
rfkill unblock wlan;
sleep 5;
#Initial wifi interface configuration
ifconfig $TO_IF up 192.168.1.1 netmask 255.255.255.0
sleep 2
###########Start dnsmasq, modify if required##########
if [ -z "$(ps -e | grep dnsmasq)" ]
then
dnsmasq
fi
###########
#Enable NAT
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface $FROM_IF -j MASQUERADE
iptables --append FORWARD --in-interface $TO_IF -j ACCEPT
#Uncomment the line below if facing problems while sharing PPPoE
#iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
sysctl -w net.ipv4.ip_forward=1
#start hostapd
echo "STARTING HOSTAPD"
hostapd /etc/hostapd/hostapd.conf
killall dnsmasq
echo "killall dnsmasq executed"
echo "Closing WiFi";
rfkill block wlan;