Skip to content

Instantly share code, notes, and snippets.

@lccxx
Last active April 18, 2017 14:15
Show Gist options
  • Save lccxx/a5f97a20c92d8163679f50e64cdcddbf to your computer and use it in GitHub Desktop.
Save lccxx/a5f97a20c92d8163679f50e64cdcddbf to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
Thread.new { system "create_ap wlp12s0 enp9s0 lc_wlan lc123789 >/dev/null 2>&1" }
999.times.each {
break if `ifconfig | grep ap0`.length != 0
sleep 1
}
puts "server is running"
cmd = <<-EOCMD
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -D POSTROUTING -o enp9s0 -j MASQUERADE >/dev/null 2>&1
iptables -t nat -A POSTROUTING -o enp9s0 -j MASQUERADE
iptables -t nat -D POSTROUTING -o ppp0 -j MASQUERADE >/dev/null 2>&1
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
EOCMD
system cmd
sudo route add -net 54.245.0.0 netmask 255.255.0.0 dev ppp0
sudo route add -net 54.186.0.0 netmask 255.255.0.0 dev ppp0
sudo route add -net 54.231.0.0 netmask 255.255.0.0 dev ppp0
sudo route add -net 176.32.0.0 netmask 255.255.0.0 dev ppp0
sudo route add -net 207.171.0.0 netmask 255.255.0.0 dev ppp0
sudo route add -net 205.251.0.0 netmask 255.255.0.0 dev ppp0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment