-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgopro.sh
executable file
·24 lines (21 loc) · 977 Bytes
/
gopro.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# gopro.sh
# Copyright (c) 2021 Dmitriy Borovikov. All rights reserved.
#
set -e
# Setup vars
GATEWAYIP=$(ip address show dev wlan0 | grep "inet " | awk '{print $2}' | cut -d/ -f1)
TARGETIP=$(ip route ls | grep "default.*wlan0" | awk '{print $3}')
# Cleanup
sudo iptables-legacy -t nat -N trident_cockpit_post || true
sudo iptables-legacy -N trident_cockpit_out || true
sudo iptables-legacy -t nat -F trident_cockpit_post
sudo iptables-legacy -F trident_cockpit_out
sudo iptables-legacy -t nat -D POSTROUTING -j trident_cockpit_post || true
sudo iptables-legacy -D OUTPUT -j trident_cockpit_out || true
# Provision
sudo iptables-legacy -t nat -A trident_cockpit_post -d $TARGETIP -j SNAT --to-source $GATEWAYIP
sudo iptables-legacy -A trident_cockpit_out -p icmp -j ACCEPT
sudo iptables-legacy -A trident_cockpit_out -s $GATEWAYIP -d 10.5.5.9 -j DROP
sudo iptables-legacy -t nat -I POSTROUTING -j trident_cockpit_post
sudo iptables-legacy -I OUTPUT -j trident_cockpit_out