LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-17-2019, 12:14 PM   #1
fruit
LQ Newbie
 
Registered: Jun 2019
Posts: 1

Rep: Reputation: Disabled
Exclamation Multiple Interfaces with different gateways


Hi,
I'm trying to configure a pc with an RJ45 NIC and a wireless interface .

the 2 are on 2 different subnets . the RJ45 is on 192.168.2.x and the wifi is on 192.168.1.x .

the following configuration doesn't work even if it makes sense to me and, as far as I can tell, it contains everything you need to make it work .

I can ping anything I'm supposed to be able to ping via local IP but the internet connection ( the gateway ) doesn't work .

/etc/network/interfaces
Code:
allow-hotplug enp3s0f2
iface enp3s0f2 inet static
        address         192.168.2.2
        netmask         255.255.255.0
	network         192.168.2.255
        dns-nameservers 208.67.220.220
        post-up ip route add 192.168.2.0/24 dev enp3s0f2 src 192.168.2.2 table rt1
	post-up ip route add default via 192.168.2.1 dev enp3s0f2 table rt1
	post-up ip rule add from 192.168.2.2/24 table rt1
	post-up ip rule add to 192.168.2.2/24 table rt1

allow-hotplug wlp2s0
iface wlp2s0 inet static
        pre-up ip link set dev wlp2s0 up
        address         192.168.1.11
        netmask         255.255.255.0
	network		192.168.1.255
        dns-nameservers 208.67.222.222
        wpa-ssid <OMISSIS>
        wpa-psk <OMISSIS>
        post-up ip route add 192.168.1.0/24 dev wlp2s0 src 192.168.1.11 table rt2
	post-up ip route add default via 192.168.1.1 dev wlp2s0 table rt2
	post-up ip rule add from 192.168.1.11/24 table rt2
	post-up ip rule add to 192.168.1.11/24 table rt2
/etc/iproute2/rt_tables
Code:
#
# reserved values
#
255	local
254	main
253	default
0	unspec
#
# local
#
#1	inr.ruhep
1 rt1
2 rt2
/etc/resolv.conf
Code:
nameserver 208.67.222.222
Code:
ip -a route
169.254.0.0/16 dev enp3s0f2 scope link metric 1000 
192.168.1.0/24 dev wlp2s0 proto kernel scope link src 192.168.1.11 
192.168.2.0/24 dev enp3s0f2 proto kernel scope link src 192.168.2.2
 
Old 06-23-2019, 06:08 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,654

Rep: Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708Reputation: 2708
what is the internal address of your router? Your device that gives your internal networks access to the itnernet should be set as your default route.
 
Old 07-13-2019, 08:40 PM   #3
scheidel21
Senior Member
 
Registered: Feb 2003
Location: CT
Distribution: Debian 6+, CentOS 5+
Posts: 1,323

Rep: Reputation: 100Reputation: 100
I believe you need to remove one of your routing tables in rt_tables and remove the post-up ip commands form the interface you want primary. Then I don't know if it makes a difference but examples I saw also added the rule before adding the default route to the routing table. The issue you seem to have is the system does not have a default route as evidences by you route output. This is probably because you are using an ip2 routign table for both interfaces, you only need routing tables for each interface that is not the primary/default. The routing tables simply ensure traffic received or explicitly sent via that interface goes back out that interface and to that network instead of trying to go out through the default interface. See http://www.allgoodbits.org/articles/view/24 for some more information the second scenario on that page is exactly what you are trying to do. At least this assumes you aren't trying to do interface failover.
 
  


Reply



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
iptables multiple interfaces same subnet to multiple vlan interfaces krobinson Linux - Server 3 04-22-2015 04:25 AM
multiple interfaces with different default gateways issue zaeem Linux - Networking 16 06-11-2010 01:10 PM
Multiple interfaces to different gateways PacketWhacker Linux - Networking 2 04-15-2009 03:44 PM
2 Interfaces with different IP and gateways; clash? Swakoo Linux - Networking 2 04-23-2008 09:06 PM
Red Hat 7.3 and multiple gateways on multiple interfaces bluefmc Linux - Networking 2 11-19-2004 05:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:19 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