I have a desktop computer running OpenSUSE 11.2 with two network cards installed. I would like to use both cards for connecting to the internet using different networks. The setting would be the following:
eth0 is the main (default) card, almost all programs should use this NIC for connecting to the internet.
eth1 is used only by a few programs, which have setting for selecting which network interface to use.
The two NIC’s are connected to different networks, so the IP address of the NIC’s, the related subnet masks and gateways are also different.
Saying short, I would like to have the two NIC’s as they would be in two separate computers.
I can set the IP address and subnet mask of the NIC’s. The main problem is that I can only declare one gateway.
How can i setup this? I do not use network manager, I configure network cards using yast, but if needed I can of course use ifconfig directly.
First, why? I do not see a benefit to trying this.
Second, the only way I think you can do this is to assign static routes to
your second NIC which go to the places those certain applications (which
can supposedly choose one NIC or the other) need to go. You can only have
default route. To have both NICs used to go anywhere I believe you must
bond them but that defeats your purpose in every use of bonding I’ve seen
(not that I have seen them all…). So if applicationA needs to go to novell.com then resolve it and define static routes using eth1 to go to
that destination so your system does not send traffic over the default
(nothing else trumps it) route.
Good luck.
On 02/09/2010 01:46 PM, katonag1 wrote:
>
> I have a desktop computer running OpenSUSE 11.2 with two network cards
> installed. I would like to use both cards for connecting to the internet
> using different networks. The setting would be the following:
>
> eth0 is the main (default) card, almost all programs should use this
> NIC for connecting to the internet.
>
> eth1 is used only by a few programs, which have setting for selecting
> which network interface to use.
>
> The two NIC’s are connected to different networks, so the IP address of
> the NIC’s, the related subnet masks and gateways are also different.
>
> Saying short, I would like to have the two NIC’s as they would be in
> two separate computers.
>
> I can set the IP address and subnet mask of the NIC’s. The main problem
> is that I can only declare one gateway.
>
> How can i setup this? I do not use network manager, I configure network
> cards using yast, but if needed I can of course use ifconfig directly.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
If one was connecting to the internet and the other to a local subnet then I would say this is very doable, but both going to the internet, the routing could be tough to do. Are they going to the internet through different devices, such as one cable and one dsl? There are routers available that will handle that.
It seems interesting. I am not an expert, so I have questions. What does IP network mean in “let $P1_NET be the IP network $P1 is in”. Is it the subnet mask?
Will this work when the traffic is initiated from my computer? The programs that would use eth1 can go to any IP address on the net, so as the programs that should use eth0.
eth0 would be connected to a Class C network, lets say the IP address is 195.7.170.5 with the gateway in 195.7.170.1 and with a subnet mask of 255.255.255.224
eth1 would be connected to a Class B private network with IP address 172.18.160.40, gateway at 172.18.160.1, subnet mask 255.255.0.0
For quite few years, I liked Solaris.
A lot of commercial networking product vendors used BSD variants (some of them were secrets!) in their products. One typical example is CISCO’s initial versions of PIX firewalls. I agree that it is easy to configure some of the stuff in *BSD (even today).
In those years, Linux was lagging behind. The biggest advancement happened when iproute2 became part of the mainstream. Also there are related technologies like LVS etc. A lot of it is not visible because of the way things need to be configured.
OK, I played around a bit, and have a moified question with a simplified situation.
For trial I have set up the two NIC’s using the same gateway, subnet, but different IP’s. Lets say I want to use eth1 for normal web browsing. connecting to ssh servers etc, and I want eth0 to run my own servers on it, eg. apache, ssh, imap
To use eth1 as the main NIC I set the default gateway for eth1, so ip route now has a line:
default via x.x.x.1 dev eth1
This way web browsing, or ssh connection uses eth1 and peers see the IP address of eth1.
The problem is that I cannot connect to the IP address of eth0 from outside the subnet, so I cannot reach my servers.
How should I set up the system to have the desired operation? The gateways are the same for eth0 and eth1, the IP’s of the two NIC only differ in the last digit: x.x.x.3 and x.x.x.4