Author Topic: [Not Possible] Choosing a NIC in the Browser  (Read 2335 times)

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
[Not Possible] Choosing a NIC in the Browser
« on: January 01, 2011, 10:54:41 AM »
Did not know how to best describe this question ......

I have two NICs in my PC.
Each is connected to a different router, on a separate LAN segment.
Both routers have internet connection.

One NIC is always default, which means all internet traffic goes out through it.

Is there a simple way to force the use of the other NIC on a connection by connection basis?

For instance, if I have Konqueror open at PCLOS forum going out through NIC#1

How can I use another instance of Konqueror or another browser to go to Google.com but this time using NIC#2

I just cannot seem to figure it out today .......  must be some simple way to do this .....

Please tell me what I am missing ........   :(   >:(
« Last Edit: January 02, 2011, 12:10:54 PM by Just19 »

Offline jschall

  • Jr. Member
  • **
  • Posts: 30
Re: Choosing a NIC
« Reply #1 on: January 01, 2011, 01:03:03 PM »
Hey, Just19.

I´ll take a stab at this, although I have never configured multiple ethernet interfaces.

If you open the PCLinuxOS Control Center, you should see an icon labeled ¨Set up a new network interface...¨. In there you will find a list of interface types, with Ethernet at the top. If you open that, you SHOULD see the two NICs, eth0 and (maybe) eth1. (In my case I only see eth0).

Beyond that I fear to tread, afraid of borking my eth0 or wlan0.

But that should get you started.

Good luck!
Jeff Schallenberg
Mont Saint Hilaire, Quebec
eeePC 701 4G, PCLOS Enlightenment Light

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Choosing a NIC
« Reply #2 on: January 01, 2011, 01:10:18 PM »
Hey, Just19.

I´ll take a stab at this, although I have never configured multiple ethernet interfaces.

If you open the PCLinuxOS Control Center, you should see an icon labeled ¨Set up a new network interface...¨. In there you will find a list of interface types, with Ethernet at the top. If you open that, you SHOULD see the two NICs, eth0 and (maybe) eth1. (In my case I only see eth0).

Beyond that I fear to tread, afraid of borking my eth0 or wlan0.

But that should get you started.

Good luck!

Thank you for the response.
I have the two NICS set up, and they are working properly.

What I need now is some way to tell the browser which NIC to use when going to a web site.

It *should* be simple .......   but heck if I can figure it out    ???

Offline Hootiegibbon

  • Hero Member
  • *****
  • Posts: 4151
Re: Choosing a NIC
« Reply #3 on: January 01, 2011, 01:11:00 PM »
Did not know how to best describe this question ......

I have two NICs in my PC.
Each is connected to a different router, on a separate LAN segment.
Both routers have internet connection.

One NIC is always default, which means all internet traffic goes out through it.

Is there a simple way to force the use of the other NIC on a connection by connection basis?

For instance, if I have Konqueror open at PCLOS forum going out through NIC#1

How can I use another instance of Konqueror or another browser to go to Google.com but this time using NIC#2

I just cannot seem to figure it out today .......  must be some simple way to do this .....

Please tell me what I am missing ........   :(   >:(

I think you need to have to seperate LAN address networks for each router

eg
10.0.0.1-10.0.0.50 = eth0 connection
192.168.0.2-192.168.0.50 = eth1 connection

then set up two proxys on the machine one that connects to the net via eth0 the other eth1

then use the proxy set ups on each app to tell the app to connect to a particular network.

Think that helps?

Jase





I am Hootiegibbon, undisputed champion fo the typo

My .dotfiles

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Choosing a NIC
« Reply #4 on: January 01, 2011, 01:21:28 PM »
Did not know how to best describe this question ......

I have two NICs in my PC.
Each is connected to a different router, on a separate LAN segment.
Both routers have internet connection.

One NIC is always default, which means all internet traffic goes out through it.

Is there a simple way to force the use of the other NIC on a connection by connection basis?

For instance, if I have Konqueror open at PCLOS forum going out through NIC#1

How can I use another instance of Konqueror or another browser to go to Google.com but this time using NIC#2

I just cannot seem to figure it out today .......  must be some simple way to do this .....

Please tell me what I am missing ........   :(   >:(


I think you need to have to seperate LAN address networks for each router

eg
10.0.0.1-10.0.0.50 = eth0 connection
192.168.0.2-192.168.0.50 = eth1 connection

then set up two proxys on the machine one that connavts to the net via eth0 the other eth1

then use the proxy set ups on each app to tell the app to connect to a particular network.

Think that helps?

Jase



Oh heck!  I was hoping there was some *simple* way to do this   :D

Yes the two NICS have access to a different range of IPs .....
a.    192.168.1.xxx
b.    192.168.3.xxx

After that I was hoping to be able to put something in the location bar of the browser, prior to the address I wanted to get to, to direct the browser which NIC to use .......  on a connection by connection basis.
In simple form

NIC#b http://www.google.com

with everything without that direction using the default.

That would allow me to connect to the internet through the two NICs in the one app, just different tabs.

Maybe it is not possible ......  but to me it seems a reasonably logical thing to want to do   ;D ;D

I guess I am spoiled ..... 

Thanks Jase.

regards.

Offline Hootiegibbon

  • Hero Member
  • *****
  • Posts: 4151
Re: Choosing a NIC
« Reply #5 on: January 01, 2011, 03:00:47 PM »
Just19,

there may be a way by using squid/bind/routing based on what you have said.

I can see the logic, although not the know-how

use a filter to get the trafic routed ?

[route1] www.whatsj19upto.com
[route2] www.probablybestnottoknow.net

Jase


I am Hootiegibbon, undisputed champion fo the typo

My .dotfiles

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Choosing a NIC
« Reply #6 on: January 01, 2011, 04:49:25 PM »
Just19,

there may be a way by using squid/bind/routing based on what you have said.

I can see the logic, although not the know-how

use a filter to get the trafic routed ?

[route1] www.whatsj19upto.com
[route2] www.probablybestnottoknow.net

Jase


I know nothing about squid/bind/routing unfortunately, so have no idea even where I might start.

On the other hand, if it would take a bit of setting up it is likely not worth the trouble.

I really thought there might be a simple "built-in" means of achieving it ......  two NICs on a motherboard are not unusual.

Presently, when I need to use the second NIC I just disable the default one.
It is a hassle, but not so much that something like squid would be a lot less hassle, I think.

I really thought there would be some simple means of directing the browser - or other app - to use the second NIC and not the default NIC when accessing the internet.

It would be nice for instance to have something running on one connection and have the freedom to use the other without interfering.

Thanks again  ;)

Offline DeBaas

  • Hero Member
  • *****
  • Posts: 1522
    • PCLinuxOS.nl
Re: Choosing a NIC
« Reply #7 on: January 02, 2011, 06:08:55 AM »
NAME
route - show / manipulate the IP routing table
SYNOPSIS
route [-CFvnee]

route
    [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn] [reinstate] [[dev] If]
route
    [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm] [metric N] [[dev] If]
route
    [-V] [--version] [-h] [--help]

DESCRIPTION
Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig(8) program.

When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Choosing a NIC
« Reply #8 on: January 02, 2011, 07:20:08 AM »
Thanks for the reply ......  maybe I am misinterpreting this ......

Quote
Its primary use is to set up static routes to specific hosts or networks

but I don't understand how that may help .......  could you give an example please?
« Last Edit: January 02, 2011, 07:22:18 AM by Just19 »

Offline DeBaas

  • Hero Member
  • *****
  • Posts: 1522
    • PCLinuxOS.nl
Re: Choosing a NIC
« Reply #9 on: January 02, 2011, 11:05:37 AM »
http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html
http://www.labtestproject.com/linnet/routing.html

You can add a route to a specific TCP adress or range trough a desired interface/NIC
from within a terminal.

Google for linux route add example

One of the examples:

   The route add command below show the example to add network and host to the routing table.

[root@linux hack]# route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 eth0

[root@linux hack]# route add -host 10.10.0.5 netmask 255.255.0.0 gw 10.2.0.1 eth0


 To verify the current change to the routing table, execute the route command without any option.
 

 The example below show the command to remove or delete routing from routing table.

[root@linux hack]# route del -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 eth0

[root@linux hack]# route del -host 10.10.0.5 netmask 255.255.0.0 gw 10.2.0.1 eth0


Happy experimenting ;)
« Last Edit: January 02, 2011, 11:12:13 AM by DeBaas »

Online muungwana

  • Hero Member
  • *****
  • Posts: 6252
Re: Choosing a NIC
« Reply #10 on: January 02, 2011, 11:53:28 AM »
Did not know how to best describe this question ......

I have two NICs in my PC.
Each is connected to a different router, on a separate LAN segment.
Both routers have internet connection.

One NIC is always default, which means all internet traffic goes out through it.

Is there a simple way to force the use of the other NIC on a connection by connection basis?

For instance, if I have Konqueror open at PCLOS forum going out through NIC#1

How can I use another instance of Konqueror or another browser to go to Google.com but this time using NIC#2

I just cannot seem to figure it out today .......  must be some simple way to do this .....

Please tell me what I am missing ........   :(   >:(
what do these commands give you?

ifconfig

route -n

The last command will show your computer's routing table, all traffic out of your computer is send to a NIC as specified in the table. If you want traffic to certain websites go through a particular NIC, you have to specify it in the routing table using the "route" command as root.

As far as i know, an application can not select what NIC card to send its output to and hence what you want can not easily be accomplished.

Big websites like google have multiple servers will multiple IP addresses for load balancing purposes. What you can do is having two google host ip addresses on your routing table and have the routing table send traffic to one address using one NIC and traffic to another address using the other NIC.

You can then have these two google addresses in your "/etc/hosts" file to tell the rest of your system what address to use with what NIC.

The route table changes everytime you restart your computer or when a NIC goes offline and hence if you want them to stick, you will have to have them in some sort of a script that run at boot time.

What you are trying to do is doable only if you want to manage traffic to a handful of hosts you already know their addresses.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Choosing a NIC
« Reply #11 on: January 02, 2011, 12:09:59 PM »

what do these commands give you?

ifconfig

route -n

The last command will show your computer's routing table, all traffic out of your computer is send to a NIC as specified in the table. If you want traffic to certain websites go through a particular NIC, you have to specify it in the routing table using the "route" command as root.

As far as i know, an application can not select what NIC card to send its output to and hence what you want can not easily be accomplished.

Big websites like google have multiple servers will multiple IP addresses for load balancing purposes. What you can do is having two google host ip addresses on your routing table and have the routing table send traffic to one address using one NIC and traffic to another address using the other NIC.

You can then have these two google addresses in your "/etc/hosts" file to tell the rest of your system what address to use with what NIC.

The route table changes everytime you restart your computer or when a NIC goes offline and hence if you want them to stick, you will have to have them in some sort of a script that run at boot time.

What you are trying to do is doable only if you want to manage traffic to a handful of hosts you already know their addresses.

Thank you.

It seems what I want to do is not possible so .........  I wanted to choose which NIC to use on a case by case basis.

Thanks to everyone for the info and suggestions.

Seems I will just have to forget it.

regards.

Online muungwana

  • Hero Member
  • *****
  • Posts: 6252
Re: [Not Possible] Choosing a NIC in the Browser
« Reply #12 on: January 02, 2011, 12:31:00 PM »

giving up so easily?  :D

you can choose what NIC to use on a case by case basis. All you will have to do is change the default gateway address before accessing the network on your way to the open web. A simple "route" command on the terminal will do it for you, it will be annoying if you change the default NIC alot but its doable.



.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: [Not Possible] Choosing a NIC in the Browser
« Reply #13 on: January 02, 2011, 12:58:33 PM »

giving up so easily?  :D

you can choose what NIC to use on a case by case basis. All you will have to do is change the default gateway address before accessing the network on your way to the open web. A simple "route" command on the terminal will do it for you, it will be annoying if you change the default NIC alot but its doable.





Yes, I think I am giving up .....  :(

Presently I am disabling the default NIC when I want to use the 2nd one for a particular purpose.
Neither that nor swapping the default is really the answer.

It reminds me of the state of things when one had more than a single audio sink ......  it was almost impossible to direct different sound sources/streams to different sinks.
Pulse Audio has seen the end of that problem.

It seems I need something similar for NICs!   ;D

.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: [Not Possible] Choosing a NIC in the Browser
« Reply #14 on: January 08, 2011, 02:18:34 PM »
I came back to this today ......  yeah I know I said I was giving up  :(  ....  don't believe everything you read  ;)

OK, I now have two NICs set up here - one is eth and the other wlan.

eth0  is the default NIC.

At times I might wish to use the other to download something .....  from some as yet unknown IP address.

So to try to duplicate this, which I can likely put in a small script if it works, I am using  whatismyip.com  in a browser to check which NIC I am using.

Code: [Select]
$ konqueror [url=http://www.whatismyip.com]www.whatismyip.com[/url]

Route returns

Quote
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.3.0     *               255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     35     0        0 wlan0
link-local      *               255.255.0.0     U     35     0        0 wlan0
link-local      *               255.255.0.0     U     1002   0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         my.router       0.0.0.0         UG    0      0        0 eth0
default         192.168.1.254   0.0.0.0         UG    35     0        0 wlan0


I want to be able to use a user script to go to the whatismyip.com address on wlan0 ......  and to go there without the script on eth0.

So far it seems that using the route command requires root privileges ......  not that I got it working even as root.

So, as I am apparently incapable of figuring this out myself, can anyone give me a command that would work in this script?

Thanks for your further attention.

regards.