Author Topic: Two WAN IP Addresses ....  (Read 2035 times)

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Two WAN IP Addresses ....
« on: July 31, 2010, 01:13:37 PM »
I have a setup with a wireless and a wired NIC.
Each is connected to a different router.
Both are capable of internet access.
In general, it seems that the wired connection takes precedence  and most if not all traffic goes through the wired connection.

From my PC I can find what my WAN IP address is by using the command

wget http://checkip.dyndns.org/ -q -O - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'

That returns my public IP address for the connection used for the command.

Is there a means by which I can force the use of the wireless connection for a command like this?

The only way I have found to do it is by temporarily killing the wired connection so that the wireles one functions by default for the internet connection.

Maybe some variation of the command to force it to use the WLAN1 wireless connection?

It is not vital, but it would save me some hassle if I could achieve it ......  even in a small script.

The routers LAN side addresses, which are dynamic, issued by DHCP, are in two different LAN segments ......  192.168.1.xy  &  192.168.3.xy

If necessary I guess the wireless IP LAN address could be made static ......  if it becomes necessary ....

Thanks for reading.

As usual suggestions welcome.

regards.

Online muungwana

  • Hero Member
  • *****
  • Posts: 6216
Re: Two WAN IP Addresses ....
« Reply #1 on: July 31, 2010, 02:44:33 PM »

Why not just turn off the interface you dont want to use?

if you do not have netApplet on your tray area, start it and then right click it->settings->watched interface and then select the one you want to get internet from.

I think this should work but i am not sure. Its been a while since i last had two interfaces capable of getting internet and i dont remember exactly how to choose which one is to be used but i remember being able to choose from the applet's options.

.. 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 Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Two WAN IP Addresses ....
« Reply #2 on: July 31, 2010, 02:50:23 PM »
This has to do with your routing tables. It's a good question. I have no idea how to answer it. But you need to inform the system exactly how addresses and ports are to be handled on which nic. Maybe you could cheat and remap wget's receiving on port 80 to something else on the wired router so the computer can differentiate the two networks.

 ???

« Last Edit: July 31, 2010, 06:30:24 PM by Chuck Chunder »
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Two WAN IP Addresses ....
« Reply #3 on: July 31, 2010, 04:38:59 PM »
Turning off the wired NIC is not an option .......  it is what I do presently and it is a hassle having to stop it and restart it again.

That is what I am trying to avoid! ......  as I mentioned above.

Something to force wget to use the wireless NIC -- maybe by specifying the LAN IP address from which to send -- would be ideal I reckon .......  I wonder if that can be done .....




Offline TerryH

  • Hero Member
  • *****
  • Posts: 559
Re: Two WAN IP Addresses ....
« Reply #4 on: July 31, 2010, 04:42:25 PM »
I would have thought that if you only have one connection provided by your ISP, that they are both connected to the same line/cable and they are sharing the same public IP address.
https://linuxcounter.net/cert/542348.png

Aussie, Aussie, Aussie........Eh!,  Eh!,  Eh!

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Two WAN IP Addresses ....
« Reply #5 on: August 04, 2010, 11:50:20 AM »
I would have thought that if you only have one connection provided by your ISP, that they are both connected to the same line/cable and they are sharing the same public IP address.

Although I never said, yes it is on ADSL line from my ISP.
Yes I have two routers and two WAN IP addresses.
I have no idea what the limit on IP addresses might be, from the ISP as I never tried connecting more than two routers.

****

Just thinking .....  looking at this another way .....  is it at all possible to determine which NIC is used for any app that is communicating on the internet?

It is like having two doors but only being able to have one open at a time .......  may as well be only one door .....  particularly if I had a second internet connection .....

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Two WAN IP Addresses ....
« Reply #6 on: September 29, 2010, 04:41:43 PM »
On this same subject, but a differently phrased question ......

I have a wireless and a wired NIC in this PC. They connect to different routers.

The wired NIC takes precedence in all communications.

Is there some way to make the wireless NIC the primary one used and the wired NIC the fail-over one?

thanks.

Online muungwana

  • Hero Member
  • *****
  • Posts: 6216
Re: Two WAN IP Addresses ....
« Reply #7 on: September 29, 2010, 11:45:25 PM »
On this same subject, but a differently phrased question ......

I have a wireless and a wired NIC in this PC. They connect to different routers.

The wired NIC takes precedence in all communications.

Is there some way to make the wireless NIC the primary one used and the wired NIC the fail-over one?

thanks.


yes, you can
open the terminal and type "route -n", what do you get? The last line is the default gateway out of your system

man pages says you enter below command as root to change the default one to the one you want

route add default gw wlan0

There are ways of making this change permanent if you want

more info on route command can be found here: http://linux.die.net/man/8/route
.. 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: Two WAN IP Addresses ....
« Reply #8 on: September 30, 2010, 01:22:43 AM »
On this same subject, but a differently phrased question ......

I have a wireless and a wired NIC in this PC. They connect to different routers.

The wired NIC takes precedence in all communications.

Is there some way to make the wireless NIC the primary one used and the wired NIC the fail-over one?

thanks.


yes, you can
open the terminal and type "route -n", what do you get? The last line is the default gateway out of your system


Not really it seems ....  with two NICs I have two defaults

Code: [Select]
[user@Dell ~]$ route -n
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.3.0     0.0.0.0         255.255.255.0   U     10     0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     35     0        0 wlan1
169.254.0.0     0.0.0.0         255.255.0.0     U     10     0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     35     0        0 wlan1
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.3.1     0.0.0.0         UG    10     0        0 eth0
0.0.0.0         192.168.1.254   0.0.0.0         UG    35     0        0 wlan1

[user@Dell ~]$ route
Kernel IP routing table

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


Quote
man pages says you enter below command as root to change the default one to the one you want

route add default gw wlan0

There are ways of making this change permanent if you want

more info on route command can be found here: http://linux.die.net/man/8/route



I will have a deeper read of the man page later today, but if you have any other comments please add them.

Maybe there is a way to re-prioritise them ......

Thanks for the response ......  maybe I will get to the bottom of this, this time around.    ;)

Online muungwana

  • Hero Member
  • *****
  • Posts: 6216
Re: Two WAN IP Addresses ....
« Reply #9 on: September 30, 2010, 01:44:00 AM »

you can try to unplug eth0 and see if its entry will go away and then plug it back in and see if it will go above wlan1 or below the one from wlan1. Using route to delete and then add a default gateway could be the way to change which one of the two will be in use by changing the way they show up on the list
.. 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: Two WAN IP Addresses ....
« Reply #10 on: September 30, 2010, 02:15:59 AM »

you can try to unplug eth0 and see if its entry will go away and then plug it back in and see if it will go above wlan1 or below the one from wlan1. Using route to delete and then add a default gateway could be the way to change which one of the two will be in use by changing the way they show up on the list


The list order does not change after disconnecting either or both NICs and reconnecting them in any order.

The priority may be held in some file someplace I guess, but it is obvious that the wired connection ALWAYS takes precedence regardless which connection is made at what time.

Something someplace must be determining this behaviour.

regards.

EDIT
           ....  something related ......
http://www.physics.umd.edu/pnce/pcs-docs/Glue/linux-route-hack.html
« Last Edit: September 30, 2010, 02:20:25 AM by JohnBoy »

smcs_steve

  • Guest
Re: Two WAN IP Addresses ....
« Reply #11 on: September 30, 2010, 03:25:32 AM »
http://superuser.com/questions/116393/linux-how-to-run-aria2-or-wget-only-through-eth0

Something like this bit? >>

wget --bind-address=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'` {URL}
« Last Edit: September 30, 2010, 03:36:12 AM by _steve »

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Two WAN IP Addresses ....
« Reply #12 on: September 30, 2010, 03:52:35 AM »
http://superuser.com/questions/116393/linux-how-to-run-aria2-or-wget-only-through-eth0

wget --bind-address=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'` {URL}


Thanks _steve ....  interesting it can be done for that application .....

vjeko

  • Guest
Re: Two WAN IP Addresses ....
« Reply #13 on: September 30, 2010, 09:41:36 AM »
could you specify some for me please:

do you have one or two adsl lines?

do you have a single or two adsl modems?

do you have one adsl modem with two routers connected to it, one wireless, other (used as ) wired one to your computer


ever got the idea (there is an option in pcc) to set failover networks, so put wifi as first, eth0 as redundant?

from there on, the fwall has to be amended

what is the general use of the setup having the single computer connected by wifi to internet, so to speak, and having it connected by cable, is it extra thruput (it will not work in case you have a single adsl modem, you can use only max as assigned by your ISP)

about having different applications use a different nic and or bandwidth, have you tried poking around the fwall and maybe some bandwidth management application? had the same idea years back, but was too complicated for no gain, so i put it aside for the time being

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Two WAN IP Addresses ....
« Reply #14 on: September 30, 2010, 10:17:41 AM »
I do not use a firewall on my PC.

There is one ADSL line connected to one modem/router.

This has Concurrent Bridging/Routing selected.

One of the outputs is connected to the input of a second router.
This router is set up to use PPoE and thus gets a different IP addtess from the ISP.

Therefore I have two IP addresses and one ADSL line and one ADSL modem. That modem has a router built in and I have a second router attached getting its own IP address.

I connect to the modem/router via wireless, and to the internal router via wire.

I hope that clarifies the setup.

***

What I want to achieve is the facility to be able to determine (ideally) which connection an application will use, or failing that, to determine which connection the PC itself will use by default for all communications.
I want to be able to change that default as it suits me.

regards.