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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-27-2015, 05:25 PM
|
#1
|
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:
|
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
|
|
|
01-27-2015, 05:41 PM
|
#2
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
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
|
|
|
01-27-2015, 05:43 PM
|
#3
|
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:
|
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
|
|
|
01-27-2015, 06:26 PM
|
#4
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
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
|
|
|
01-27-2015, 09:57 PM
|
#5
|
Moderator
Registered: Mar 2008
Posts: 22,361
|
Guess you could set metric on them too.
|
|
|
01-27-2015, 10:20 PM
|
#6
|
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:
|
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
|
|
|
01-27-2015, 10:54 PM
|
#7
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
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
|
|
|
01-27-2015, 11:47 PM
|
#8
|
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:
|
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
|
|
|
01-28-2015, 03:08 PM
|
#9
|
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:
|
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.
|
|
|
All times are GMT -5. The time now is 01:48 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|