public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Multiple addresses/routes for one ethernet card possible?
@ 2020-10-24  4:55 Walter Dnes
  2020-10-24  7:35 ` Adam Carter
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Walter Dnes @ 2020-10-24  4:55 UTC (permalink / raw
  To: Gentoo Users List

  After an outage on VDSL last month, I got a backup 10/1 cable
subscription backup.  Switching is a bit of a hassle.  In addition to
swapping cables, I have to run dhcpcd as root or sudo when swithching
from VDSL to cable.  Switching back I have to run "dhcpcd -x", copy over
my backup of /etc/resolve.conf, and run "/etc/init.d/net.eth0 restart".

  The VDSL router/modem offers dhcp and static address space at
192.168.1.0/24, DNS and default GW 192.168.1.1.  I've bought a router
that gets a WAN address from the cable modem via dhcpcd, and offers dhcp
and static address space at 192.168.10.0/24, DNS and default GW
192.168.10.1. My current /etc/conf.d/net is...

mtu_eth0="1466"
config_eth0="
192.168.1.249/24 broadcast 192.168.1.255"
routes_eth0="
default via 192.168.1.1 metric 20
192.168.1.240/28 via 192.168.1.1 metric 0"

...for my machine 192.168.1.249.  Can I have something like...

mtu_eth0="1466"
config_eth0="
192.168.1.249/24 broadcast 192.168.1.255
192.168.10.249/24 broadcast 192.168.1.255"
routes_eth0="
default via 192.168.1.1 metric 20
192.168.1.240/28 via 192.168.1.1 metric 0"

... and how would I tweak the last two lines to work without changes
each time I switch between VDSL (192.168.1.1) and cable (192.168.10.1) ?

-- 
Walter Dnes <waltdnes@waltdnes.org>
I don't run "desktop environments"; I run useful applications


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
  2020-10-24  4:55 [gentoo-user] Multiple addresses/routes for one ethernet card possible? Walter Dnes
@ 2020-10-24  7:35 ` Adam Carter
  2020-10-24  8:23 ` Peter Humphrey
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Adam Carter @ 2020-10-24  7:35 UTC (permalink / raw
  To: Gentoo User

[-- Attachment #1: Type: text/plain, Size: 2462 bytes --]

On Sat, Oct 24, 2020 at 3:56 PM Walter Dnes <waltdnes@waltdnes.org> wrote:

>   After an outage on VDSL last month, I got a backup 10/1 cable
> subscription backup.  Switching is a bit of a hassle.  In addition to
> swapping cables, I have to run dhcpcd as root or sudo when swithching
> from VDSL to cable.  Switching back I have to run "dhcpcd -x", copy over
> my backup of /etc/resolve.conf, and run "/etc/init.d/net.eth0 restart".
>
>   The VDSL router/modem offers dhcp and static address space at
> 192.168.1.0/24, DNS and default GW 192.168.1.1.  I've bought a router
> that gets a WAN address from the cable modem via dhcpcd, and offers dhcp
> and static address space at 192.168.10.0/24, DNS and default GW
> 192.168.10.1. My current /etc/conf.d/net is...
>
> mtu_eth0="1466"
> config_eth0="
> 192.168.1.249/24 broadcast 192.168.1.255"
> routes_eth0="
> default via 192.168.1.1 metric 20
> 192.168.1.240/28 via 192.168.1.1 metric 0"
>
> ...for my machine 192.168.1.249.  Can I have something like...
>
> mtu_eth0="1466"
> config_eth0="
> 192.168.1.249/24 broadcast 192.168.1.255
> 192.168.10.249/24 broadcast 192.168.1.255"
> routes_eth0="
> default via 192.168.1.1 metric 20
> 192.168.1.240/28 via 192.168.1.1 metric 0"
>

For secondary IPs use eth0:0 as the interface name;
# ifconfig bond1
bond1: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.1.252  netmask 255.255.255.0  broadcast 192.168.1.255
        ether aa:86:b3:f6:ee:97  txqueuelen 1000  (Ethernet)
        RX packets 647891  bytes 867479673 (827.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 337624  bytes 114478897 (109.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ifconfig bond1:0 192.168.10.249/24
# ifconfig bond1:0
bond1:0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.10.249  netmask 255.255.255.0  broadcast 192.168.10.255
        ether aa:86:b3:f6:ee:97  txqueuelen 1000  (Ethernet)

For the routes, your eth0:0 interface will of course need to use
192.168.10.1

However, if you just have a PC with a single interface, and you are going
to just manually plug in which ever router you want to use, then just use
dhcp on eth0, and plug/replug the cable. The loss of link on the cable
should cause dhcp to DISCOVER again, and then get the correct IP and
gateway - so no changes will be required on the PC (assuming i understand
your setup correctly)

[-- Attachment #2: Type: text/html, Size: 3674 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
  2020-10-24  4:55 [gentoo-user] Multiple addresses/routes for one ethernet card possible? Walter Dnes
  2020-10-24  7:35 ` Adam Carter
@ 2020-10-24  8:23 ` Peter Humphrey
  2020-10-24  8:41 ` Michael
  2020-10-24 16:42 ` J. Roeleveld
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Humphrey @ 2020-10-24  8:23 UTC (permalink / raw
  To: gentoo-user

On Saturday, 24 October 2020 04:55:54 -00 Walter Dnes wrote:
>   After an outage on VDSL last month, I got a backup 10/1 cable
> subscription backup.  Switching is a bit of a hassle.  In addition to
> swapping cables, I have to run dhcpcd as root or sudo when swithching
> from VDSL to cable.  Switching back I have to run "dhcpcd -x", copy over
> my backup of /etc/resolve.conf, and run "/etc/init.d/net.eth0 restart".

I can't help with the other things, but '/etc/init.d/net.eth0 restart' will 
create a new /etc/resolv.conf, overwriting what you've just written.

-- 
Regards,
Peter.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
  2020-10-24  4:55 [gentoo-user] Multiple addresses/routes for one ethernet card possible? Walter Dnes
  2020-10-24  7:35 ` Adam Carter
  2020-10-24  8:23 ` Peter Humphrey
@ 2020-10-24  8:41 ` Michael
  2020-10-24 15:33   ` Walter Dnes
  2020-10-24 16:42 ` J. Roeleveld
  3 siblings, 1 reply; 7+ messages in thread
From: Michael @ 2020-10-24  8:41 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 2950 bytes --]

On Saturday, 24 October 2020 05:55:54 BST Walter Dnes wrote:
>   After an outage on VDSL last month, I got a backup 10/1 cable
> subscription backup.  Switching is a bit of a hassle.  In addition to
> swapping cables, I have to run dhcpcd as root or sudo when swithching
> from VDSL to cable.  Switching back I have to run "dhcpcd -x", copy over
> my backup of /etc/resolve.conf, and run "/etc/init.d/net.eth0 restart".
> 
>   The VDSL router/modem offers dhcp and static address space at
> 192.168.1.0/24, DNS and default GW 192.168.1.1.  I've bought a router
> that gets a WAN address from the cable modem via dhcpcd, and offers dhcp
> and static address space at 192.168.10.0/24, DNS and default GW
> 192.168.10.1. My current /etc/conf.d/net is...
> 
> mtu_eth0="1466"
> config_eth0="
> 192.168.1.249/24 broadcast 192.168.1.255"
> routes_eth0="
> default via 192.168.1.1 metric 20
> 192.168.1.240/28 via 192.168.1.1 metric 0"
> 
> ...for my machine 192.168.1.249.  Can I have something like...
> 
> mtu_eth0="1466"
> config_eth0="
> 192.168.1.249/24 broadcast 192.168.1.255
> 192.168.10.249/24 broadcast 192.168.1.255"
> routes_eth0="
> default via 192.168.1.1 metric 20
> 192.168.1.240/28 via 192.168.1.1 metric 0"
> 
> ... and how would I tweak the last two lines to work without changes
> each time I switch between VDSL (192.168.1.1) and cable (192.168.10.1) ?


In file '/usr/share/doc/netifrc-0.7.1/net.example.bz2' examples are given to 
set up interface gateways using arping.  In your case I think something like 
this ought to work:

###############
mtu_eth0="1466"

gateways_eth0="192.168.1.1 192.168.10.1"

config_192168001001="192.168.1.249/24"
routes_192168001001="default via 192.168.1.1"
dns_servers_192168001001="192.168.1.1"

config_192168010001="192.168.10.249/24"
routes_192168010001="default via 192.168.10.1"
dns_servers_192168010001="192.168.10.1"
###############

If you physically plug and unplug the ethernet cable from the PC to either 
router each time, the PC's IP address will be set statically according to the 
router's LAN address.

However, if only one router is connected to the PC at any time, my personal 
preference would be to use the *same* LAN subnet on both routers and configure 
the routers' static IP address allocation to the same IP address for the PC's 
MAC.

An alternative would be to have the PC connected to both routers over a 
managed switch and then use a more involved configuration to monitor the VDSL 
connection by pinging an Internet address, or the next hop to the ISP's 
gateway, or their DNS servers.  When multiple pings fail, the routing would be 
switched over from VDSL to the Cable router.  This would be a more convoluted 
set up, probably using a post-up script to do the failover monitoring and re-
routing.  I don't have a working netifrc setup to share, but professional 
grade managed switches/routers should be able to do this if you don't want to 
do it on the PC itself.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
  2020-10-24  8:41 ` Michael
@ 2020-10-24 15:33   ` Walter Dnes
  2020-10-24 16:12     ` Michael
  0 siblings, 1 reply; 7+ messages in thread
From: Walter Dnes @ 2020-10-24 15:33 UTC (permalink / raw
  To: gentoo-user

On Sat, Oct 24, 2020 at 09:41:01AM +0100, Michael wrote

> However, if only one router is connected to the PC at any time, my
> personal preference would be to use the *same* LAN subnet on both
> routers and configure the routers' static IP address allocation to
> the same IP address for the PC's MAC.

  I'll look into the "advanced settings menu" on both routers and see if
I can change the LAN subnet.  I want to avoid dhcp so that I can backup
and transfer files and ssh between machines using short names in
/etc/hosts rather than fiddle around with literal IP addresses.

-- 
Walter Dnes <waltdnes@waltdnes.org>
I don't run "desktop environments"; I run useful applications


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
  2020-10-24 15:33   ` Walter Dnes
@ 2020-10-24 16:12     ` Michael
  0 siblings, 0 replies; 7+ messages in thread
From: Michael @ 2020-10-24 16:12 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

On Saturday, 24 October 2020 16:33:44 BST Walter Dnes wrote:
> On Sat, Oct 24, 2020 at 09:41:01AM +0100, Michael wrote
> 
> > However, if only one router is connected to the PC at any time, my
> > personal preference would be to use the *same* LAN subnet on both
> > routers and configure the routers' static IP address allocation to
> > the same IP address for the PC's MAC.
> 
>   I'll look into the "advanced settings menu" on both routers and see if
> I can change the LAN subnet.  I want to avoid dhcp so that I can backup
> and transfer files and ssh between machines using short names in
> /etc/hosts rather than fiddle around with literal IP addresses.

You should be able to do both of your required functions.

Almost all routers I've come across have the capability of configuring their 
LAN subnet, static LAN client IPs for selected MAC addresses, and setting host 
names to resolve to static LAN IPs.  So the routers' configuration should be 
able to achieve all of your desired functionality.  In any case, additionally 
setting /etc/hosts locally will similarly direct clients to preconfigured 
static IPs without resolving the host names in either router.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
  2020-10-24  4:55 [gentoo-user] Multiple addresses/routes for one ethernet card possible? Walter Dnes
                   ` (2 preceding siblings ...)
  2020-10-24  8:41 ` Michael
@ 2020-10-24 16:42 ` J. Roeleveld
  3 siblings, 0 replies; 7+ messages in thread
From: J. Roeleveld @ 2020-10-24 16:42 UTC (permalink / raw
  To: gentoo-user

On 24 October 2020 06:55:54 CEST, Walter Dnes <waltdnes@waltdnes.org> wrote:
>  After an outage on VDSL last month, I got a backup 10/1 cable
>subscription backup.  Switching is a bit of a hassle.  In addition to
>swapping cables, I have to run dhcpcd as root or sudo when swithching
>from VDSL to cable.  Switching back I have to run "dhcpcd -x", copy
>over
>my backup of /etc/resolve.conf, and run "/etc/init.d/net.eth0 restart".
>
>  The VDSL router/modem offers dhcp and static address space at
>192.168.1.0/24, DNS and default GW 192.168.1.1.  I've bought a router
>that gets a WAN address from the cable modem via dhcpcd, and offers
>dhcp
>and static address space at 192.168.10.0/24, DNS and default GW
>192.168.10.1. My current /etc/conf.d/net is...
>
>mtu_eth0="1466"
>config_eth0="
>192.168.1.249/24 broadcast 192.168.1.255"
>routes_eth0="
>default via 192.168.1.1 metric 20
>192.168.1.240/28 via 192.168.1.1 metric 0"
>
>...for my machine 192.168.1.249.  Can I have something like...
>
>mtu_eth0="1466"
>config_eth0="
>192.168.1.249/24 broadcast 192.168.1.255
>192.168.10.249/24 broadcast 192.168.1.255"
>routes_eth0="
>default via 192.168.1.1 metric 20
>192.168.1.240/28 via 192.168.1.1 metric 0"
>
>... and how would I tweak the last two lines to work without changes
>each time I switch between VDSL (192.168.1.1) and cable (192.168.10.1)
>?

There are routers that support multiple WAN connections, removing the need to do this yourself.

Alternatively, get a simple PC with multiple network cards to act as the router.

--
Joost
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-24 16:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-24  4:55 [gentoo-user] Multiple addresses/routes for one ethernet card possible? Walter Dnes
2020-10-24  7:35 ` Adam Carter
2020-10-24  8:23 ` Peter Humphrey
2020-10-24  8:41 ` Michael
2020-10-24 15:33   ` Walter Dnes
2020-10-24 16:12     ` Michael
2020-10-24 16:42 ` J. Roeleveld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox