LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-27-2015, 05:25 PM   #1
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Rep: Reputation: 30
I have 4 nics, how do I choose which one browses the internet?


So I have a little test linux vps setup with ubuntu. I want to find out how to browse the internet (ports 80 and 443) and specify which network interface is used.

Ideally, I'd be able to run a bash command to change which interface is used. So the default is eth0. I want to use eth1 though and not interact at all with eth0. Later on though, I'll want to run eth0 and not interact with eth1.

Other than ifconfig up and ifconfig down, how can I do this?

-Thanks
 
Old 01-27-2015, 05:41 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
Are all eth0-eth3 configured on the same subnet and connected to the default gateway? Or do you just want to set an IP for one of those so that it can reach the router?

jlinkels
 
Old 01-27-2015, 05:43 PM   #3
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
The thing is that I ssh into the vps, so I'd like to be able to do this without getting disconnected by an ip change. All are connected to the default gateway.

I'd like to something like: Run a script for eth0.sh. Then all web browsers go out as eth0's ip address. Then I could run eth1.sh and all web browsers go out as eth1's ip address
 
Old 01-27-2015, 06:26 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
I haven't tested it, but I can imagine it is something like:
Code:
route add default gw 192.168.1.254 eth0
And change it with:
Code:
route add default gw 192.168.1.254 eth1
You might have to delete the existing default gw first.
Code:
route del default gw 192.168.1.254
If you are connected on the same subnet this should not break your SSH connection. Then the box doesn't need a default gw to get back to you.

jlinkels
 
Old 01-27-2015, 09:57 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,047

Rep: Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632
Guess you could set metric on them too.
 
Old 01-27-2015, 10:20 PM   #6
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
When I do a route -n, it says the gateway is 0.0.0.0 as well as destination and genmask.

So I tried your command:

sudo route add default gw 0.0.0.0 eth1

and I got SIOCADDRT: Invalid argument
 
Old 01-27-2015, 10:54 PM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
The default gateway must be something on the same subnet as the network interface. So configure the network interface correctly, then set the default gw to something on the same subnet.

And study the route command. If you want to make a setup like this (why do you want that anyway?) you might want to understand what the idea behind routes is.

jlinkels
 
Old 01-27-2015, 11:47 PM   #8
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
Ok, I am very lost. I can't find my route -n results anywhere on the internet. Here is my /etc/network/interfaces file. Maybe that will help. IP addresses have been changed though.

# Auto generated lo interface
auto lo
iface lo inet loopback

# Auto generated venet0 interface
auto venet0
iface venet0 inet manual
up ifconfig venet0 up
up ifconfig venet0 127.0.0.2
up route add default dev venet0
down route del default dev venet0
down ifconfig venet0 down


iface venet0 inet6 manual
up route -A inet6 add default dev venet0
down route -A inet6 del default dev venet0

auto venet0:0
iface venet0:0 inet static
address 10.10.13.12
netmask 255.255.255.255

auto venet0:1
iface venet0:1 inet static
address 10.10.13.136
netmask 255.255.255.255

auto venet0:2
iface venet0:2 inet static
address 10.10.13.15
netmask 255.255.255.255

auto venet0:3
iface venet0:3 inet static
address 10.10.13.13
netmask 255.255.255.255

auto venet0:4
iface venet0:4 inet static
address 10.10.13.14
netmask 255.255.255.255


-Thanks
 
Old 01-28-2015, 03:08 PM   #9
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
I think I figured it out. I can run this command to change the route:

sudo route add -net 0.0.0.0/0 dev venet0:3

That changes my ip to show that of the venet0:3 card. Then I can do a "sudo route del default" to change it back to the default.

Thanks for the help. It got me in the right direction.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fedora 7 machine browses the Internet on DHCP but fails completely on static address simbini Linux - Newbie 5 08-05-2010 01:27 AM
XP browses but cant activate. phantom_cyph General 2 02-26-2007 08:53 PM
NICs and Internet - Need Help theGrayFox Linux - Hardware 3 06-30-2004 04:53 AM
Two nics, no internet Cheza Linux - Wireless Networking 1 05-06-2004 12:01 PM
Only browses internet with IP address timmywo Linux - Newbie 6 11-02-2003 03:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration