Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a Linux box with two different NICs that are connected to two different networks, but they share the same IP range (10.0.0.x). My first idea was to use virtualization for that (i.e., Xen), but it seems to me overkill since I want to use the same programs without conflicts due routing.

I was wandering if there is a way to confine a NIC to something like a shell session, so all programs launched from there use only that NIC, like launching a bash session that only sees eth1 but not eth0.

edit: I guess I'm looking something similar to FreeBSD jails but for Linux

share|improve this question
    
I have the same problem from superuser.com/questions/263360/openvpn-client-as-socks-5-server/… Which openvpn client software could conveniently create a "Host-only Networking just like vmware" so that i can use it as a socks5 proxy? For example: my pc is 192.168.0.2 and 192.168.10.1 without openvpn client connected, and the openvpn client in this pc may get 192.168.0.2 ip from the remote openvpn server,so i want to make the virtual network of openvpn client is host-only network(eg. don't influence the local network), and it has a NAT ip 192.168.10.2 for host(my pc) to access it –  diyism Dec 23 '11 at 4:09
    
Maybe more simple question is: How to create host only networking without virtual machine? –  diyism Dec 23 '11 at 5:48
    
We do something similar here. But we use the routing tables. And it isn't very elegant. –  surfasb Dec 23 '11 at 6:40

3 Answers 3

If both the network address and subnet masks for the two separate networks are identical, your network is misconfigured in a way that defeats the basic intent of IP-routing.

I would renumber one of the networks.

share|improve this answer
    
I don't understand what are you trying to say with 'misconfigured', two different networks can have the same IP address block. Indeed, most (if not all) home routers share the same IP range: 10.0.0.0 or 192.168.0.0. The problem is mine, since I need to use both networks at the same time. Sadly, I can't re-assign addresses since those networks aren't under my control. –  Carlos Dec 21 '11 at 17:24
    
While those are private blocks and reused throughout the world, by 'misconfigured', he means that if there are multiple routes to the same IP address, and they are different physical hosts, then your networking configuration will not work correctly when you try to address that IP. If I can't say '192.168.0.2' from your computer and refer to exactly one computer, then you need to reconfigure how your network is set up. If you can't do that, then you'll need to find something that can do NAT before packets get to your computer (like a router). –  Darth Android Dec 21 '11 at 18:15
    
@Carlos: as Darth says, separately administered networks that use the same private network address are not directly bridged by any single computer, they are necessarily linked only by routers that use Network Address Translation(NAT) and at least one intervening network (even if it is only a two-node network) with a public (and therefore differing and unique) network address. –  RedGrittyBrick Dec 21 '11 at 19:38

Hmm, it seems I'm not describing well my problem. - @Darth Android At best, 'misconfigured' is infortunate to describe the situation: you're correct that this scenario generates a conflict in the routing table, but I'm trying to find a solution for that having two routes isolated from each other. The other solution would be using a proxy NAT, but it seems to me much more complicated than just running Linux virtualized inside a VM, like Xen. - @RedGrittyBrick I'm not trying to bridge two separate networks, I'm trying to access two seperate netowrks that use the same IP block.

I found two jails equivalents for Linux that do network isolation, it seems they'll do trick:

share|improve this answer

Your question sounds like it's a job for network namespaces (url is related, not official). Using this technology appears to be relatively new as of this writing and I'm finding quite difficult to find concise HOWTOs that would also explain what's actually happening with each command. Googling "ip netns" (with and without quotes) would probably get you best started putting pieces together.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.