Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
e9c47c39
Commit
e9c47c39
authored
7 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
vpn ip range
parent
1ed9361f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-utils-firewall
+4
-13
4 additions, 13 deletions
src/freedombone-utils-firewall
with
4 additions
and
13 deletions
src/freedombone-utils-firewall
+
4
−
13
View file @
e9c47c39
...
@@ -110,15 +110,13 @@ function enable_ipv6 {
...
@@ -110,15 +110,13 @@ function enable_ipv6 {
echo
1
>
/proc/sys/net/ipv6/conf/all/forwarding
echo
1
>
/proc/sys/net/ipv6/conf/all/forwarding
}
}
function
firewall_
update_external_ip
{
function
update_external_ip
{
ip_update_script
=
/usr/bin/externalipupdate
ip_update_script
=
/usr/bin/externalipupdate
echo
'#!/bin/bash'
>>
$ip_update_script
echo
'#!/bin/bash'
>>
$ip_update_script
echo
"existing_ip=
\$
(cat
$CONFIGURATION_FILE
| grep
\"
EXTERNAL_IPV4_ADDRESS=
\"
| head -n 1 | awk -F '=' '{print
\$
2}')'"
>>
$ip_update_script
echo
"existing_ip=
\$
(cat
$CONFIGURATION_FILE
| grep
\"
EXTERNAL_IPV4_ADDRESS=
\"
| head -n 1 | awk -F '=' '{print
\$
2}')'"
>>
$ip_update_script
echo
"curr_ip=
\$
(nslookup .
$EXTERNAL_IP_LOOKUP_URL
| grep Address | tail -n 1 | awk -F ' ' '{print
\$
2}')"
>>
$ip_update_script
echo
"curr_ip=
\$
(nslookup .
$EXTERNAL_IP_LOOKUP_URL
| grep Address | tail -n 1 | awk -F ' ' '{print
\$
2}')"
>>
$ip_update_script
echo
'if [[ "$curr_ip" != "$existing_ip" ]]; then'
>>
$ip_update_script
echo
'if [[ "$curr_ip" != "$existing_ip" ]]; then'
>>
$ip_update_script
echo
" sed -i
\"
s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=
\$
{curr_ip}|g
\"
$CONFIGURATION_FILE
"
>>
$ip_update_script
echo
" sed -i
\"
s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=
\$
{curr_ip}|g
\"
$CONFIGURATION_FILE
"
>>
$ip_update_script
echo
" iptables -t nat -D POSTROUTING -s
\$
{curr_ip}/24 -o
${
FIREWALL_EIFACE
}
-j MASQUERADE"
>>
$ip_update_script
echo
" iptables -t nat -A POSTROUTING -s
\$
{curr_ip}/24 -o
${
FIREWALL_EIFACE
}
-j MASQUERADE"
>>
$ip_update_script
echo
' iptables-save > /etc/firewall.conf'
>>
$ip_update_script
echo
' iptables-save > /etc/firewall.conf'
>>
$ip_update_script
echo
'fi'
>>
$ip_update_script
echo
'fi'
>>
$ip_update_script
...
@@ -126,35 +124,28 @@ function firewall_update_external_ip {
...
@@ -126,35 +124,28 @@ function firewall_update_external_ip {
}
}
function
firewall_disable_vpn
{
function
firewall_disable_vpn
{
read_config_param EXTERNAL_IPV4_ADDRESS
if
[
!
$EXTERNAL_IPV4_ADDRESS
]
;
then
return
fi
sed
-i
'/externalipupdate/d'
/etc/crontab
iptables
-D
INPUT
-i
${
FIREWALL_EIFACE
}
-m
state
--state
NEW
-p
udp
--dport
1194
-j
ACCEPT
iptables
-D
INPUT
-i
${
FIREWALL_EIFACE
}
-m
state
--state
NEW
-p
udp
--dport
1194
-j
ACCEPT
iptables
-D
INPUT
-i
tun+
-j
ACCEPT
iptables
-D
INPUT
-i
tun+
-j
ACCEPT
iptables
-D
FORWARD
-i
tun+
-j
ACCEPT
iptables
-D
FORWARD
-i
tun+
-j
ACCEPT
iptables
-D
FORWARD
-i
tun+
-o
${
FIREWALL_EIFACE
}
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-D
FORWARD
-i
tun+
-o
${
FIREWALL_EIFACE
}
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-D
FORWARD
-i
${
FIREWALL_EIFACE
}
-o
tun+
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-D
FORWARD
-i
${
FIREWALL_EIFACE
}
-o
tun+
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-t
nat
-D
POSTROUTING
-s
${
EXTERNAL_IPV4_ADDRESS
}
/24
-o
${
FIREWALL_EIFACE
}
-j
MASQUERADE
iptables
-t
nat
-D
POSTROUTING
-s
10.8.0.0
/24
-o
${
FIREWALL_EIFACE
}
-j
MASQUERADE
iptables
-D
OUTPUT
-o
tun+
-j
ACCEPT
iptables
-D
OUTPUT
-o
tun+
-j
ACCEPT
save_firewall_settings
save_firewall_settings
sed
-i
'/VPN=/d'
$FIREWALL_CONFIG
sed
-i
'/VPN=/d'
$FIREWALL_CONFIG
}
}
function
firewall_enable_vpn
{
function
firewall_enable_vpn
{
curr_external_ipv4_address
=
$(
get_external_ipv4_address
)
iptables
-A
INPUT
-i
${
FIREWALL_EIFACE
}
-m
state
--state
NEW
-p
udp
--dport
1194
-j
ACCEPT
iptables
-A
INPUT
-i
${
FIREWALL_EIFACE
}
-m
state
--state
NEW
-p
udp
--dport
1194
-j
ACCEPT
iptables
-A
INPUT
-i
tun+
-j
ACCEPT
iptables
-A
INPUT
-i
tun+
-j
ACCEPT
iptables
-A
FORWARD
-i
tun+
-j
ACCEPT
iptables
-A
FORWARD
-i
tun+
-j
ACCEPT
iptables
-A
FORWARD
-i
tun+
-o
${
FIREWALL_EIFACE
}
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-A
FORWARD
-i
tun+
-o
${
FIREWALL_EIFACE
}
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-A
FORWARD
-i
${
FIREWALL_EIFACE
}
-o
tun+
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-A
FORWARD
-i
${
FIREWALL_EIFACE
}
-o
tun+
-m
state
--state
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-t
nat
-A
POSTROUTING
-s
${
curr_external_ipv4_address
}
/24
-o
${
FIREWALL_EIFACE
}
-j
MASQUERADE
iptables
-t
nat
-A
POSTROUTING
-s
10.8.0.0
/24
-o
${
FIREWALL_EIFACE
}
-j
MASQUERADE
iptables
-A
OUTPUT
-o
tun+
-j
ACCEPT
iptables
-A
OUTPUT
-o
tun+
-j
ACCEPT
write_config_param EXTERNAL_IPV4_ADDRESS
"
$curr_external_ipv4_address
"
save_firewall_settings
save_firewall_settings
firewall_update_external_ip
echo
"VPN=1194"
>>
$FIREWALL_CONFIG
echo
"VPN=1194"
>>
$FIREWALL_CONFIG
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment