Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Smart-building MSE-Lab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LSDS
Smart-building MSE-Lab
Commits
cc72afc1
Commit
cc72afc1
authored
5 years ago
by
marcoemi.poleggi
Browse files
Options
Downloads
Patches
Plain Diff
Better internet_sharing
parent
53e97789
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
util/internet-sharing
+42
-6
42 additions, 6 deletions
util/internet-sharing
with
43 additions
and
7 deletions
README.md
+
1
−
1
View file @
cc72afc1
...
...
@@ -41,7 +41,7 @@ reroute all incoming traffic from, say, `eth0` (where your Raspberry is
connected to) through your wireless connection
`wlan0`
, you'd call the script
like this (as
**superuser**
):
```
# ./util/internet-sharing wlan0 eth0
# ./util/internet-sharing wlan0 eth0
start
```
To make the changes persistent, consult your Linux distribution's documentation.
...
...
This diff is collapsed.
Click to expand it.
util/internet-sharing
+
42
−
6
View file @
cc72afc1
...
...
@@ -8,11 +8,47 @@
# <https://wiki.archlinux.org/index.php/Internet_sharing>
# <https://linoxide.com/firewall/ip-forwarding-connecting-private-interface-internet/>
################################################################################
gwint
=
${
1
:-
'net0'
}
# internet gateway interface -- all outbound traffic
clint
=
${
2
:-
'net1'
}
# client interface -- input traffic
usage
=
$(
cat
<<
EOF
Usage:
sysctl net.ipv4.ip_forward
=
1 net.ipv6.conf.default.forwarding
=
1 net.ipv6.conf.all.forwarding
=
1
$0
GWINTERFACE CLINTERFACE COMMAND
iptables
-t
nat
-A
POSTROUTING
-o
$gwint
-j
MASQUERADE
iptables
-A
FORWARD
-m
conntrack
--ctstate
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-A
FORWARD
-i
$clint
-o
$gwint
-j
ACCEPT
where:
GWINTERFACE internet gateway interface -- all outbound traffic, e.g. "net0"
CLINTERFACE client interface -- input traffic, e.g. "net1"'
COMMAND "start", "stop" or "restart"
EOF
)
function
do_start
{
sysctl net.ipv4.ip_forward
=
1 net.ipv6.conf.default.forwarding
=
1 net.ipv6.conf.all.forwarding
=
1
iptables
-t
nat
-A
POSTROUTING
-o
$gwint
-j
MASQUERADE
iptables
-A
FORWARD
-m
conntrack
--ctstate
RELATED,ESTABLISHED
-j
ACCEPT
iptables
-A
FORWARD
-i
$clint
-o
$gwint
-j
ACCEPT
}
function
do_stop
{
sysctl net.ipv4.ip_forward
=
0 net.ipv6.conf.default.forwarding
=
0 net.ipv6.conf.all.forwarding
=
0
iptables
-F
iptables
-t
nat
-F
}
gwint
=
${
1
:?
'arg #1 missing: internet gateway interface -- all outbound traffic, e.g. "net0"'
}
clint
=
${
2
:?
'arg #2 missing: client interface -- input traffic, e.g. "net1"'
}
cmmnd
=
${
3
:?
'arg #3 missing: command (start, stop, restart)'
}
case
$cmmnd
in
start
)
do_start
;;
stop
)
do_stop
;;
restart
)
do_stop
&&
do_start
;;
*
)
echo
>
&2
"[error]
$cmmnd
: invalid command"
echo
>
&2
"
${
usage
}
"
esac
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