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
zhifan huang
re6stnet
Commits
2477ff52
Commit
2477ff52
authored
Sep 10, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate default route
parent
a24ecb2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
+25
-10
demo/demo
demo/demo
+17
-2
re6st/plib.py
re6st/plib.py
+7
-7
re6stnet
re6stnet
+1
-1
No files found.
demo/demo
View file @
2477ff52
#!/usr/bin/python
#!/usr/bin/python
import math, nemu, os, signal, socket, subprocess, sys, time
import math, nemu, os, signal, socket, subprocess, sys, time
, weakref
from collections import defaultdict
from collections import defaultdict
IPTABLES = 'iptables'
IPTABLES = 'iptables'
SCREEN = 'screen'
SCREEN = 'screen'
...
@@ -26,6 +26,12 @@ def disable_signal_on_children(sig):
...
@@ -26,6 +26,12 @@ def disable_signal_on_children(sig):
sigint = signal.signal(sig, lambda *x: os.getpid() == pid and sigint(*x))
sigint = signal.signal(sig, lambda *x: os.getpid() == pid and sigint(*x))
disable_signal_on_children(signal.SIGINT)
disable_signal_on_children(signal.SIGINT)
Node__add_interface = nemu.Node._add_interface
def _add_interface(node, iface):
iface.__dict__['node'] = weakref.proxy(node)
return Node__add_interface(node, iface)
nemu.Node._add_interface = _add_interface
# create nodes
# create nodes
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
...
@@ -95,6 +101,7 @@ in_if_0.add_v4_address(address='10.0.0.1', prefix_len=24)
...
@@ -95,6 +101,7 @@ in_if_0.add_v4_address(address='10.0.0.1', prefix_len=24)
in_if_1.add_v4_address(address='10.1.0.1', prefix_len=24)
in_if_1.add_v4_address(address='10.1.0.1', prefix_len=24)
in_if_2.add_v4_address(address='10.2.0.1', prefix_len=24)
in_if_2.add_v4_address(address='10.2.0.1', prefix_len=24)
in_if_3.add_v4_address(address='10.0.1.1', prefix_len=24)
in_if_3.add_v4_address(address='10.0.1.1', prefix_len=24)
in_if_3.add_v6_address(address='2001:db8::1', prefix_len=48)
g1_if_0.add_v4_address(address='10.1.0.2', prefix_len=24)
g1_if_0.add_v4_address(address='10.1.0.2', prefix_len=24)
g1_if_1.add_v4_address(address='10.1.1.1', prefix_len=24)
g1_if_1.add_v4_address(address='10.1.1.1', prefix_len=24)
g2_if_0.add_v4_address(address='10.2.0.2', prefix_len=24)
g2_if_0.add_v4_address(address='10.2.0.2', prefix_len=24)
...
@@ -108,9 +115,17 @@ m6_if_0.add_v4_address(address='10.0.1.2', prefix_len=24)
...
@@ -108,9 +115,17 @@ 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)
def add_llrtr(iface, peer, dst='default'):
for a in peer.get_addresses():
a = a['address']
if a.startswith('fe80:'):
return iface.node.Popen(('ip', 'route', 'add', dst, 'via', a,
'proto', 'static', 'dev', iface.name)).wait()
# setup routes
# setup routes
add_llrtr(re_if_0, in_if_0)
add_llrtr(in_if_0, re_if_0, '2001:db8:42::/48')
registry.add_route(prefix='10.0.0.0', prefix_len=8, nexthop='10.0.0.1')
registry.add_route(prefix='10.0.0.0', prefix_len=8, nexthop='10.0.0.1')
#internet.add_route(prefix='10.1.0.0', prefix_len=16, nexthop='10.1.0.2')
internet.add_route(prefix='10.2.0.0', prefix_len=16, nexthop='10.2.0.2')
internet.add_route(prefix='10.2.0.0', prefix_len=16, nexthop='10.2.0.2')
gateway1.add_route(prefix='10.0.0.0', prefix_len=8, nexthop='10.1.0.1')
gateway1.add_route(prefix='10.0.0.0', prefix_len=8, nexthop='10.1.0.1')
gateway2.add_route(prefix='10.0.0.0', prefix_len=8, nexthop='10.2.0.1')
gateway2.add_route(prefix='10.0.0.0', prefix_len=8, nexthop='10.2.0.1')
...
...
re6st/plib.py
View file @
2477ff52
...
@@ -52,22 +52,22 @@ def client(iface, server_address, encrypt, *args, **kw):
...
@@ -52,22 +52,22 @@ def client(iface, server_address, encrypt, *args, **kw):
return
openvpn
(
iface
,
encrypt
,
*
remote
,
**
kw
)
return
openvpn
(
iface
,
encrypt
,
*
remote
,
**
kw
)
def
router
(
network
,
subnet
,
hello_interval
,
log_path
,
state_path
,
pidfile
,
def
router
(
subnet
,
hello_interval
,
gateway
,
log_path
,
state_path
,
pidfile
,
tunnel_interfaces
,
*
args
,
**
kw
):
tunnel_interfaces
,
*
args
,
**
kw
):
s
=
utils
.
ipFromBin
(
subnet
)
s
=
utils
.
ipFromBin
(
subnet
)
n
=
len
(
subnet
)
n
=
len
(
subnet
)
cmd
=
[
'babeld'
,
cmd
=
[
'babeld'
,
'-C'
,
'redistribute local deny'
,
'-C'
,
'redistribute ip %s/%u eq %u'
%
(
s
,
n
,
n
),
'-C'
,
'redistribute deny'
,
#'-C', 'in ip %s/%u' % (utils.ipFromBin(network), len(network)),
#'-C', 'in deny',
'-h'
,
str
(
hello_interval
),
'-h'
,
str
(
hello_interval
),
'-H'
,
str
(
hello_interval
),
'-H'
,
str
(
hello_interval
),
'-L'
,
log_path
,
'-L'
,
log_path
,
'-S'
,
state_path
,
'-S'
,
state_path
,
'-I'
,
pidfile
,
'-I'
,
pidfile
,
'-s'
]
'-s'
,
'-C'
,
'redistribute local deny'
,
'-C'
,
'redistribute ip %s/%u eq %u'
%
(
s
,
n
,
n
),
'-C'
,
'redistribute deny'
]
if
gateway
:
cmd
[
-
2
:
-
2
]
=
'-C'
,
'redistribute ip ::/0 eq 0'
for
iface
in
tunnel_interfaces
:
for
iface
in
tunnel_interfaces
:
cmd
+=
'-C'
,
'interface %s rxcost 512'
%
iface
cmd
+=
'-C'
,
'interface %s rxcost 512'
%
iface
cmd
+=
args
cmd
+=
args
...
...
re6stnet
View file @
2477ff52
...
@@ -181,7 +181,7 @@ def main():
...
@@ -181,7 +181,7 @@ def main():
tunnel_manager
=
write_pipe
=
None
tunnel_manager
=
write_pipe
=
None
config
.
babel_args
+=
config
.
iface_list
config
.
babel_args
+=
config
.
iface_list
cleanup
=
[
plib
.
router
(
network
,
subnet
,
config
.
hello
,
cleanup
=
[
plib
.
router
(
subnet
,
config
.
hello
,
tunnel_manager
is
not
None
,
os
.
path
.
join
(
config
.
log
,
'babeld.log'
),
os
.
path
.
join
(
config
.
log
,
'babeld.log'
),
os
.
path
.
join
(
config
.
state
,
'babeld.state'
),
os
.
path
.
join
(
config
.
state
,
'babeld.state'
),
config
.
babel_pidfile
,
tunnel_interfaces
,
config
.
babel_pidfile
,
tunnel_interfaces
,
...
...
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