Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joanne Hugé
re6stnet
Commits
f2b67235
Commit
f2b67235
authored
Sep 21, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New --daemon option
parent
361129da
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
9 deletions
+37
-9
demo/demo
demo/demo
+8
-5
demo/m6/re6stnet.conf
demo/m6/re6stnet.conf
+3
-0
docs/re6stnet.rst
docs/re6stnet.rst
+12
-0
re6st/utils.py
re6st/utils.py
+1
-2
re6stnet
re6stnet
+13
-2
No files found.
demo/demo
View file @
f2b67235
...
@@ -17,8 +17,8 @@ REGISTRY='10.0.0.2'
...
@@ -17,8 +17,8 @@ REGISTRY='10.0.0.2'
# gateway1 gateway2 s3:10.0.1
# gateway1 gateway2 s3:10.0.1
# |.1 |.1 |.2 |.3 |.4
# |.1 |.1 |.2 |.3 |.4
# s1:10.1.1 s2:10.2.1 m6 m7 m8
# s1:10.1.1 s2:10.2.1 m6 m7 m8
# |.2 |.3 |.2 |.3 |.4
# |.2 |.3 |.2 |.3 |.4
|
# m1 m2 m3 m4 m5
# m1 m2 m3 m4 m5
m9
#
#
def disable_signal_on_children(sig):
def disable_signal_on_children(sig):
...
@@ -36,7 +36,7 @@ nemu.Node._add_interface = _add_interface
...
@@ -36,7 +36,7 @@ nemu.Node._add_interface = _add_interface
for name in """internet=I registry=R
for name in """internet=I registry=R
gateway1=g1 machine1=1 machine2=2
gateway1=g1 machine1=1 machine2=2
gateway2=g2 machine3=3 machine4=4 machine5=5
gateway2=g2 machine3=3 machine4=4 machine5=5
machine6=6 machine7=7 machine8=8
machine6=6 machine7=7 machine8=8
machine9=9
""".split():
""".split():
name, short = name.split('=')
name, short = name.split('=')
globals()[name] = node = nemu.Node()
globals()[name] = node = nemu.Node()
...
@@ -56,12 +56,14 @@ switch3 = nemu.Switch()
...
@@ -56,12 +56,14 @@ switch3 = nemu.Switch()
re_if_0, in_if_0 = nemu.P2PInterface.create_pair(registry, internet)
re_if_0, in_if_0 = nemu.P2PInterface.create_pair(registry, internet)
in_if_1, g1_if_0 = nemu.P2PInterface.create_pair(internet, gateway1)
in_if_1, g1_if_0 = nemu.P2PInterface.create_pair(internet, gateway1)
in_if_2, g2_if_0 = nemu.P2PInterface.create_pair(internet, gateway2)
in_if_2, g2_if_0 = nemu.P2PInterface.create_pair(internet, gateway2)
m6_if_1, m9_if_0 = nemu.P2PInterface.create_pair(machine6, machine9)
g1_if_0_name = g1_if_0.name
g1_if_0_name = g1_if_0.name
gateway1.Popen((IPTABLES, '-t', 'nat', '-A', 'POSTROUTING', '-o', g1_if_0_name, '-j', 'MASQUERADE')).wait()
gateway1.Popen((IPTABLES, '-t', 'nat', '-A', 'POSTROUTING', '-o', g1_if_0_name, '-j', 'MASQUERADE')).wait()
gateway1.Popen((IPTABLES, '-t', 'nat', '-N', 'MINIUPNPD')).wait()
gateway1.Popen((IPTABLES, '-t', 'nat', '-N', 'MINIUPNPD')).wait()
gateway1.Popen((IPTABLES, '-t', 'nat', '-A', 'PREROUTING', '-i', g1_if_0_name, '-j', 'MINIUPNPD')).wait()
gateway1.Popen((IPTABLES, '-t', 'nat', '-A', 'PREROUTING', '-i', g1_if_0_name, '-j', 'MINIUPNPD')).wait()
gateway1.Popen((IPTABLES, '-N', 'MINIUPNPD')).wait()
gateway1.Popen((IPTABLES, '-N', 'MINIUPNPD')).wait()
machine9.Popen(('sysctl', 'net.ipv6.conf.%s.accept_ra=2' % m9_if_0.name)).wait()
in_if_3 = nemu.NodeInterface(internet)
in_if_3 = nemu.NodeInterface(internet)
g1_if_1 = nemu.NodeInterface(gateway1)
g1_if_1 = nemu.NodeInterface(gateway1)
...
@@ -93,7 +95,7 @@ switch3.connect(m8_if_0)
...
@@ -93,7 +95,7 @@ switch3.connect(m8_if_0)
# setting everything up
# setting everything up
switch1.up = switch2.up = switch3.up = True
switch1.up = switch2.up = switch3.up = True
re_if_0.up = in_if_0.up = in_if_1.up = g1_if_0.up = in_if_2.up = g2_if_0.up = True
re_if_0.up = in_if_0.up = in_if_1.up = g1_if_0.up = in_if_2.up = g2_if_0.up = True
in_if_3.up = g1_if_1.up = g2_if_1.up = m1_if_0.up = m2_if_0.up = m3_if_0.up = m4_if_0.up = m5_if_0.up = m6_if_0.up = m
7_if_0.up = m8
_if_0.up = True
in_if_3.up = g1_if_1.up = g2_if_1.up = m1_if_0.up = m2_if_0.up = m3_if_0.up = m4_if_0.up = m5_if_0.up = m6_if_0.up = m
6_if_1.up = m7_if_0.up = m8_if_0.up = m9
_if_0.up = True
# Add IPv4 addresses
# Add IPv4 addresses
re_if_0.add_v4_address(address=REGISTRY, prefix_len=24)
re_if_0.add_v4_address(address=REGISTRY, prefix_len=24)
...
@@ -114,6 +116,7 @@ m5_if_0.add_v4_address(address='10.2.1.4', prefix_len=24)
...
@@ -114,6 +116,7 @@ m5_if_0.add_v4_address(address='10.2.1.4', prefix_len=24)
m6_if_0.add_v4_address(address='10.0.1.2', prefix_len=24)
m6_if_0.add_v4_address(address='10.0.1.2', prefix_len=24)
m7_if_0.add_v4_address(address='10.0.1.3', prefix_len=24)
m7_if_0.add_v4_address(address='10.0.1.3', prefix_len=24)
m8_if_0.add_v4_address(address='10.0.1.4', prefix_len=24)
m8_if_0.add_v4_address(address='10.0.1.4', prefix_len=24)
m6_if_1.add_v4_address(address='192.168.241.1', prefix_len=24)
def add_llrtr(iface, peer, dst='default'):
def add_llrtr(iface, peer, dst='default'):
for a in peer.get_addresses():
for a in peer.get_addresses():
...
@@ -194,7 +197,7 @@ if 1:
...
@@ -194,7 +197,7 @@ if 1:
re6stnet(machine3, 'm3', '-i%s' % m3_if_0.name)
re6stnet(machine3, 'm3', '-i%s' % m3_if_0.name)
re6stnet(machine4, 'm4', '-i%s' % m4_if_0.name)
re6stnet(machine4, 'm4', '-i%s' % m4_if_0.name)
re6stnet(machine5, 'm5', '-i%s' % m5_if_0.name)
re6stnet(machine5, 'm5', '-i%s' % m5_if_0.name)
re6stnet(machine6, 'm6')
re6stnet(machine6, 'm6'
, '-I%s' % m6_if_1.name
)
re6stnet(machine7, 'm7')
re6stnet(machine7, 'm7')
re6stnet(machine8, 'm8')
re6stnet(machine8, 'm8')
db.close()
db.close()
...
...
demo/m6/re6stnet.conf
View file @
f2b67235
...
@@ -9,3 +9,6 @@ cert m6/cert.crt
...
@@ -9,3 +9,6 @@ cert m6/cert.crt
key
m6
/
cert
.
key
key
m6
/
cert
.
key
client
-
count
2
client
-
count
2
tunnel
-
refresh
100
tunnel
-
refresh
100
# TODO: Run a DHCPv4 client on machine9. Unfortunately, isc-dhcp-client 4.2.4
# fails with "Bind socket to interface: No such device"
daemon
"exec dnsmasq -d8 - -i $re6stnet_iface -F 192.168.42.2,192.168.42.254,255.255.255.0,infinite -F ${re6stnet_subnet%/*},ra-only,${re6stnet_subnet#*/},1d -O option:router,192.168.42.1 -l m6/dnsmasq.leases"
docs/re6stnet.rst
View file @
f2b67235
...
@@ -36,6 +36,18 @@ use it for communications that are unrelated to this network, then:
...
@@ -36,6 +36,18 @@ use it for communications that are unrelated to this network, then:
trigger SLAAC with ``rdisc6 <iface>`` to restore the default route if the
trigger SLAAC with ``rdisc6 <iface>`` to restore the default route if the
kernel removed while enabling forwarding.
kernel removed while enabling forwarding.
Following environment variables are available for processes started with
``--up`` or ``--daemon``:
re6stnet_iface
value of ``--main-interface`` option
re6stnet_ip
IPv6 set on main interface
re6stnet_subnet
your subnet, written in CIDR notation
re6stnet_network
the re6st network you belong to, written in CIDR notation
HOW TO
HOW TO
======
======
...
...
re6st/utils.py
View file @
f2b67235
...
@@ -78,8 +78,7 @@ class ArgParser(argparse.ArgumentParser):
...
@@ -78,8 +78,7 @@ class ArgParser(argparse.ArgumentParser):
" Serial number defines the prefix of the network."
" Serial number defines the prefix of the network."
def
convert_arg_line_to_args
(
self
,
arg_line
):
def
convert_arg_line_to_args
(
self
,
arg_line
):
arg_line
=
arg_line
.
split
(
'#'
,
1
)[
0
].
rstrip
()
if
arg_line
.
split
(
'#'
,
1
)[
0
].
rstrip
():
if
arg_line
:
if
arg_line
.
startswith
(
'@'
):
if
arg_line
.
startswith
(
'@'
):
yield
arg_line
yield
arg_line
return
return
...
...
re6stnet
View file @
f2b67235
...
@@ -37,6 +37,10 @@ def getConfig():
...
@@ -37,6 +37,10 @@ def getConfig():
" tunnelling can be chosen."
)
" tunnelling can be chosen."
)
_
(
'--up'
,
metavar
=
'CMD'
,
_
(
'--up'
,
metavar
=
'CMD'
,
help
=
"Shell command to run after successful initialization."
)
help
=
"Shell command to run after successful initialization."
)
_
(
'--daemon'
,
action
=
'append'
,
metavar
=
'CMD'
,
help
=
"Same as --up, but run in background: the command will be killed"
" at exit (with a TERM signal, followed by KILL 5 seconds later"
" if process is still alive)."
)
_
=
parser
.
add_argument_group
(
'routing'
).
add_argument
_
=
parser
.
add_argument_group
(
'routing'
).
add_argument
_
(
'-B'
,
dest
=
'babel_args'
,
metavar
=
'ARG'
,
action
=
'append'
,
default
=
[],
_
(
'-B'
,
dest
=
'babel_args'
,
metavar
=
'ARG'
,
action
=
'append'
,
default
=
[],
...
@@ -175,6 +179,12 @@ def main():
...
@@ -175,6 +179,12 @@ def main():
try
:
try
:
subnet
=
network
+
prefix
subnet
=
network
+
prefix
my_ip
=
'%s/%s'
%
(
utils
.
ipFromBin
(
subnet
,
'1'
),
len
(
subnet
))
my_ip
=
'%s/%s'
%
(
utils
.
ipFromBin
(
subnet
,
'1'
),
len
(
subnet
))
my_subnet
=
'%s/%u'
%
(
utils
.
ipFromBin
(
subnet
),
len
(
subnet
))
my_network
=
"%s/%u"
%
(
utils
.
ipFromBin
(
network
),
len
(
network
))
os
.
environ
[
're6stnet_ip'
]
=
my_ip
os
.
environ
[
're6stnet_iface'
]
=
config
.
main_interface
os
.
environ
[
're6stnet_subnet'
]
=
my_subnet
os
.
environ
[
're6stnet_network'
]
=
my_network
# Init db and tunnels
# Init db and tunnels
tunnel_interfaces
=
server_tunnels
.
keys
()
tunnel_interfaces
=
server_tunnels
.
keys
()
...
@@ -195,7 +205,6 @@ def main():
...
@@ -195,7 +205,6 @@ def main():
cleanup
=
[]
cleanup
=
[]
try
:
try
:
my_network
=
"%s/%u"
%
(
utils
.
ipFromBin
(
network
),
len
(
network
))
# Source address selection is defined by RFC 3484, and in most
# Source address selection is defined by RFC 3484, and in most
# applications, it usually works thanks to rule 5 (prefer outgoing
# applications, it usually works thanks to rule 5 (prefer outgoing
# interface). But here, it rarely applies because we use several
# interface). But here, it rarely applies because we use several
...
@@ -229,7 +238,7 @@ def main():
...
@@ -229,7 +238,7 @@ def main():
# WKRD: Removed this useless route now, since the kernel does
# WKRD: Removed this useless route now, since the kernel does
# not even remove it on exit.
# not even remove it on exit.
subprocess
.
call
(
if_rt
)
subprocess
.
call
(
if_rt
)
if_rt
[
4
]
=
'%s/%u'
%
(
utils
.
ipFromBin
(
subnet
),
len
(
subnet
))
if_rt
[
4
]
=
my_subnet
cleanup
.
append
(
lambda
:
subprocess
.
call
(
if_rt
))
cleanup
.
append
(
lambda
:
subprocess
.
call
(
if_rt
))
x
=
[
my_network
]
x
=
[
my_network
]
if
config
.
table
:
if
config
.
table
:
...
@@ -258,6 +267,8 @@ def main():
...
@@ -258,6 +267,8 @@ def main():
r
=
os
.
system
(
config
.
up
)
r
=
os
.
system
(
config
.
up
)
if
r
:
if
r
:
sys
.
exit
(
r
)
sys
.
exit
(
r
)
for
cmd
in
config
.
daemon
or
():
cleanup
.
append
(
utils
.
Popen
(
cmd
,
shell
=
True
).
stop
)
# main loop
# main loop
if
tunnel_manager
is
None
:
if
tunnel_manager
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment