Editing
RestrictingVserverNetworkingTips
(section)
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Network-local guest == We now describe a configuration that leads to a guest that can (''a priori'') only connect to the host and can be reached via the network only from the host. Define an interface using <tt>dummy0</tt> as the value of <tt>dev</tt> and an <tt>ip</tt> value like <tt>192.168.x.y</tt> or <tt>10.x.y.z</tt> which is not an existing external-facing interface address for the host. (You may need to <tt>modprobe dummy</tt> in order to create such an interface.) The guest can now connect to '''any''' service on the host that is listening for connections to <tt><IP address>:80</tt>; where the IP address must be the one chosen above or the wildcard <tt>0.0.0.0</tt>. For example, if the host is running a web server that listens to <tt>0.0.0.0</tt>, then (in the guest) one can run the command <blockquote> socat - TCP:192.168.x.y:80 </blockquote> to connect to this server; where as before <tt>192.168.x.y</tt> is the chosen IP address. On the guest, this command is '''equivalent''' to the command <blockquote> socat - TCP:127.0.0.1:80 </blockquote> Note that the address 127.0.0.1 '''on the guest''' is '''equivalent''' to the chosen IP address but '''not''' on the host. Similarly, the guest can start servers that listen to <tt>192.168.x.y:8888</tt> or <tt>0.0.0.0:8888</tt> providing that there is no server that is already listening to this address (on the guest '''or''' on the host). The host can connect to such a server using the command <blockquote> socat - TCP:192.168.x.y:80 </blockquote> Both the above type of connections, <tt>guest-to-host</tt> or <tt>host-to-guest</tt> happen over the loopback network interface. Suppose you do not want the guest to access services on the host and vice versa. Then you use <tt>netfilter</tt> to limit connections over the loopback port. For example, <blockquote> iptables -I INPUT -d ! 127.0.0.1 -i lo -j DROP </blockquote> One can restrict specific services by more specific netfilter rules. For example, we can use <blockquote> iptables -I INPUT -i lo -p tcp --dport 80 -j ACCEPT </blockquote> to allow the guest to access the web server on the host and vice versa. '''Warning''': With this configuration the guest will "pollute" the network neighbourhood with packets whose source address is the given IP address. So it is best to use netfilter to prevent this with a configuration like <blockquote> iptables -I OUTPUT -s 192.168.x.y -d ! lo -j DROP </blockquote>
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information