[emanicslab] EmanicsLab - LXC - Bind ports to public IP address

David Hausheer hausheer at ps.tu-darmstadt.de
Wed Mar 19 22:06:37 CET 2014


Dear EmanicsLab users,

The new EmanicsLab version is based on LXC instead of vserver. Each 
slice runs in its own LXC instance on a node.

Moreover, each LXC instance has its own *private* IP address. By 
default, sockets are connected to this private IP address.

However, by using a kernel module called "transforward", a process 
running in the slice can bind a socket to the node's public address, 
too. For this, the public address of the node has to be specified 
explicitly.

For example, in Apache this can be done with the "Listen" Directive:

Listen 128.112.95.146:80

See below an example python script, which binds a socket to a port under 
the node's public IP address:

#!/usr/bin/python

import socket

host = '128.112.95.146'  # the public IP address of the node
port = 13412
s = socket.socket()
print s.bind((host,port))
s.listen(10)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
     data = conn.recv(1024)
     if not data: break
     conn.send(data)
conn.close()

Best regards
David

-- 
Prof. Dr. David Hausheer

Technische Universitaet Darmstadt
Dept. of Electrical Engineering & Information Technology

Rundeturmstr. 10, Building S3/20, Room 225
64283 Darmstadt, Germany
Phone: +49 6151 16 4280
Fax: +49 6151 16 6152
E-Mail: hausheer at ps.tu-darmstadt.de
Web: http://www.ps.tu-darmstadt.de/


More information about the emanicslab mailing list