Editing
Msg09838.html
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!
----- [<nowiki/>[[msg09837.html|Date Prev]]][<nowiki/>[[msg09839.html|Date Next]]][<nowiki/>[[msg09837.html|Thread Prev]]][<nowiki/>[[msg09884.html|Thread Next]]][<nowiki/>[[index.html#09838|Date Index]]][<nowiki/>[[threads.html#09838|Thread Index]]] <span id="re-vserver-confused-by-routing"></span> = Re: [Vserver] Confused by routing = ----- * '''From:''' Herbert Poetzl * '''Date:''' Fri, 27 May 2005 12:35:18 +0200 (CEST) ----- <pre>On Fri, May 27, 2005 at 12:24:12PM +0200, Herbert Poetzl wrote: > > Hi Gilles! > > here is an example setup how to accomplish your 'funny' > routing scenario ... enjoy! > > > > +---------------------+ > | | > | Host 1 | > | | +-------------------+ > | 192.168.0.1/24 | | | > | | | Host2 (FW) | > | 172.16.0.2/16 | | | > | 172.17.0.2/16 | | 192.168.0.2/24 | > | | | | > | +-----------------+ | | 172.16.0.2/16 | > | | | | eth0.2 | 172.17.0.2/16 | > | | Guest 1 | | 172.16.0.0/16 | | > | | +----------------------+ | > | | 172.16.0.1/16 | | | ` | > | | | | | ¦ | > | +-----------------+ | | ¦ | > | | | ¦ rules | > | +-----------------+ | | ¦ | > | | | | eth0.3 | ¦ | > | | Guest 2 | | 172.17.0.0/16 | , | > | | +----------------------+ | > | | 172.17.0.1/16 | | | | > | | | | +-------------------+ > | +-----------------+ | > | | > +---------------------+ > > > Tested as two QEMU instances connected via a simple > bridging setup on the real machine ... > > Bridge on Real: > =============== > > ifconfig tun0 0.0.0.0 up > ifconfig tun1 0.0.0.0 up > > brctl addbr br0 > brctl addif br0 tun0 > brctl addif br0 tun1 > > > Host 1 Setup: > ============= > > /* basic network setup for QEMU */ > ifconfig lo 127.0.0.1 > ifconfig eth0 hw ether 00:00:00:00:00:01 > ifconfig eth0 192.168.0.1 > > /* create VLAN taggings */ > vconfig add eth0 2 > vconfig add eth0 3 > > /* configure interfaces */ > ifconfig eth0.2 172.16.0.1 > ifconfig eth0.3 172.17.0.1 > > Host 2 Setup: > ============= > > /* basic network setup for QEMU */ > ifconfig lo 127.0.0.1 > ifconfig eth0 hw ether 00:00:00:00:00:02 > ifconfig eth0 192.168.0.2 > > /* create VLAN taggings */ > vconfig add eth0 2 > vconfig add eth0 3 > > /* configure interfaces */ > ifconfig eth0.2 172.16.0.2 > ifconfig eth0.3 172.17.0.2 > > > Host 1 Magic: > ============= > > /* default gw for Guest 1 */ > ip rule add from 172.16.0.1 table 16 > ip route add default via 172.16.0.2 table 16 > ip route del 172.16.0.0/16 > > /* default gw for Guest 2 */ > ip rule add from 172.17.0.1 table 17 > ip route add default via 172.17.0.2 table 17 > ip route del 172.17.0.0/16 > > /* nat to avoid local table */ > iptables -t nat -A OUTPUT -d 172.17.0.1 -j DNAT --to 172.17.1.1 > iptables -t nat -A OUTPUT -d 172.16.0.1 -j DNAT --to 172.16.1.1 if you want to see the 'correct' IPs on Host 1 too, just add the following rules: iptables -t nat -A POSTROUTING -s 172.17.1.1 -j SNAT --to 172.17.0.1 iptables -t nat -A POSTROUTING -s 172.16.1.1 -j SNAT --to 172.16.0.1 (somehow I didn't care though) > > Host 2 Magic: > ============= > > /* enable forwarding */ > echo 1 >/proc/sys/net/ipv4/ip_forward > > /* nat between 172.16.1.1 and 172.16.0.1 */ > iptables -t nat -A PREROUTING -d 172.16.1.1 -j DNAT --to 172.16.0.1 > iptables -t nat -A POSTROUTING -s 172.16.0.1 -j SNAT --to 172.16.1.1 > > /* nat between 172.17.1.1 and 172.17.0.1 */ > iptables -t nat -A PREROUTING -d 172.17.1.1 -j DNAT --to 172.17.0.1 > iptables -t nat -A POSTROUTING -s 172.17.0.1 -j SNAT --to 172.17.1.1 > > > _______________________________________________ > Vserver mailing list > Vserver@xxxxxxxxxxxxxxxxxxxxxx > http://list.linux-vserver.org/mailman/listinfo/vserver </pre> ----- * '''Follow-Ups''': ** '''[[msg09884.html|Re: [Vserver] Confused by routing]]''' *** ''From:'' Gilles * '''References''': ** '''[[msg09818.html|[Vserver] Confused by routing]]''' *** ''From:'' Gilles ** '''[[msg09837.html|Re: [Vserver] Confused by routing]]''' *** ''From:'' Herbert Poetzl * Prev by Date: '''[[msg09837.html|Re: [Vserver] Confused by routing]]''' * Next by Date: '''[[msg09839.html|Re: [Vserver] Confused by routing]]''' * Previous by thread: '''[[msg09837.html|Re: [Vserver] Confused by routing]]''' * Next by thread: '''[[msg09884.html|Re: [Vserver] Confused by routing]]''' * Index(es): ** [[index.html#09838|'''Date''']] ** [[threads.html#09838|'''Thread''']]
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