LinuxQuestions.org
Visit Jeremy's Blog.
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 10-02-2014, 06:33 PM   #1
jnbb
LQ Newbie
 
Registered: Oct 2012
Posts: 8

Rep: Reputation: Disabled
[PARTIALLY SOLVED] Configuring default gateway, multihomed host


I run Linux Mint 17 on a desktop PC. My adsl router is too far away to connect by cable, so I have a USB wireless adaptor to communicate with it. I also have a wired ethernet router alongside the computer into which I can plug my NAS box, printer and laptop.

I would like to be able to surf the net, and keep the NAS box on-line, but cannot presently achieve it. Using NetworkManager to disable the wired interface, I can reach the internet, but not my wired hosts; and vice versa if I enable eth0.

My wireless router gives out, via its dhcp server, an address of 192.168.0.2
My wired router gives out, via its dhcp server, an address of 192.168.1.2

With the wired interface disabled, the output of the route command is:
Code:
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
192.168.0.0     *               255.255.255.0   U     9      0        0 wlan0
with the wired interface enabled, I get:
Code:
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     9      0        0 wlan0
192.168.1.0     *               255.255.255.0   U     1      0        0 eth0
I would like to make the wlan0 interface the default for all IP requests outside the range 192.168.1.0 to 192.168.1.255 (i.e. the internet). Is there a way to do this? I've tried various commands to 'route' but can never get the default to stick to the wlan0 interface AND have eth0 available.

Last edited by jnbb; 10-03-2014 at 06:30 AM. Reason: Partial solution discovered
 
Old 10-02-2014, 06:39 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Because your wired router issues a DHCP address including a default GW.

Either configure your desktop manually (IP, netmask, DNS, default GW) or tell your wired router to set the default gw to your wireless router. Sometimes the default GW cannot be set as DHCP option so then you must configure it manually.

jlinkels
 
Old 10-03-2014, 06:28 AM   #3
jnbb
LQ Newbie
 
Registered: Oct 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thank you, jlinkels, for your reply. There does not appear to be an option on the wired router to set the default gw, so I have configured it thus:

1. Turned off DHCP
2. Configured a static IP address for the PC, 192.168.1.2

Using NetworkManager on the PC I have configured the ethernet port thus, in 'IPv4 Settings':

Method: Manual
Address: 192.168.1.2 Netmask: 255.255.255.0 Gateway: 192.168.1.1

So far I have exactly the same situation as in my original post. But now I am able to change the default:

Code:
# route del default
# route add default gw 192.168.0.1
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
192.168.0.0     *               255.255.255.0   U     9      0        0 wlan0
192.168.1.0     *               255.255.255.0   U     1      0        0 eth0
Success! Well, partial. Now I have to find a way to automate the changing of the default gw.
 
Old 10-03-2014, 12:49 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If it is true what you say --you cannot configure the wired DHCP def gw-- then there is no solution. Because it means that the wire DHCP server will always give out the def gw pointing to it self. So you get an IP, you get the def gw for free.

Networkmanager won't help you here. You cannot accept a dynamic address but ignore the def gw.

There is a proposed solution here: http://askubuntu.com/questions/15260...hcp-interfaces

It assignes a default gw to eth0 while it is still using DHCP to acquire an IP. I am not sure it will work. If it works, the manual specification seems to have preference over the DHCP. It is worth a try.

Note however that when you mention eth0 in network/interfaces, it will not be managed anymore by networkmanager. You can leave you wlan0 in networkmanager though.

Don't forget to add
Code:
auto eth0
before the
Code:
iface eth0...
line.

jlinkels
 
Old 10-03-2014, 02:13 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
The problem is you have two separate networks, one with internet access, one without. You should look into a way to simplify things - one network, one "main" router, and the other can just act as a bridge. You can't run a single cat 5e/6 cable through the wall from your dsl router to the other router? If you can pull that off, then you can switch off DHCP on your other router so it just acts like a switch and everything is controlled by the dsl router.
 
Old 10-03-2014, 05:01 PM   #6
jnbb
LQ Newbie
 
Registered: Oct 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
As I understand DHCP, neither the offer packet DHCPOFFER nor the acknowledgement packet DHCPACK define the default gateway (Wikipedia: http://en.wikipedia.org/wiki/Dynamic...ation_Protocol ). Of course they define a gateway IP address GIADDR, otherwise the DHCP broadcast appeal wouldn't know who to talk to. But the default 0.0.0.0 is being assigned after the interfaces have got their IP addresses, and indeed the 'route' man page makes it clear that a static address must exist before it can be used as the default.

How is the default gw assigned? The man pages for 'ip', 'route', 'ifconfig' and 'dhcpd' do not mention this.

jlinkels, I have read the post at http://askubuntu.com/questions/15260...hcp-interfaces where the poster appears to be basically asking the same question.

suicidaleggroll - kind suggestion but not currently practical. Also, I like learning how things work!
 
Old 10-03-2014, 05:15 PM   #7
jnbb
LQ Newbie
 
Registered: Oct 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Since post #6, I have found two further useful links which I'll follow up. Looks as though I'll have to abandon NetworkManager:

http://serverfault.com/questions/527...t-a-route-push

http://xmodulo.com/how-to-set-defaul...-in-linux.html
 
Old 10-03-2014, 07:36 PM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Well, I really think that DHCP assigns the default gw. Below is a snippet from my own DHCP server. And I am pretty sure that when I need to assign a different default gw, I do it here. Done that before.
Code:
subnet 192.168.110.0 netmask 255.255.255.0 {
  range 192.168.110.60 192.168.110.119;
  option domain-name-servers 192.168.110.10;
  option domain-name "megaline.com";
  option routers 192.168.110.10;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.110.255;
  default-lease-time 600;
  max-lease-time 7200;
}
About abandoning networkmanager. When you describe an interface in /etc/network/interfaces NM doesn't use it. So that would only be eth0. You can still have NM handle wlan0 which I would really recommend.

jlinkels
jlinkels
 
Old 10-04-2014, 05:29 AM   #9
jnbb
LQ Newbie
 
Registered: Oct 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
jlinkels - I understand. Because I cannot control this setting on my router via its web interface, I will enter the wired interface in /etc/network/interfaces, and will keep NetworkManager for wlan0 as you suggest.

One day I'll have a go at installing dd-wrt on the router (an ancient Netgear WGR614) and wrestle back control of it.

Thank you for your patient help.
 
  


Reply

Tags
gateway, multihomed



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
LXer: Configuring Default Gateway on RedHat Enterprise Linux LXer Syndicated Linux News 0 07-16-2014 08:01 AM
[SOLVED] Different default gateway for one host nuvista175 Linux - Networking 6 01-23-2012 02:27 AM
Forwarding multicast packets with iptables and multihomed Debian gateway Mogget Linux - Networking 1 09-20-2011 04:25 PM
Configuring default gateway on Red Hat linuxcares12 Linux - Networking 3 11-02-2009 04:04 AM
non-default route to static host through gateway for ppp failover testing jrscandora Linux - Networking 3 04-21-2009 02:20 AM

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

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