Gentoo Archives: gentoo-user

From: Adam Carter <adamcarter3@×××××.com>
To: Gentoo User <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] Multiple addresses/routes for one ethernet card possible?
Date: Sat, 24 Oct 2020 07:36:01
Message-Id: CAC=wYCFxyaY_tH7NzBJCTN0689XO3ZLGBhcE7RBN+rNhZoXkmA@mail.gmail.com
In Reply to: [gentoo-user] Multiple addresses/routes for one ethernet card possible? by Walter Dnes
1 On Sat, Oct 24, 2020 at 3:56 PM Walter Dnes <waltdnes@××××××××.org> wrote:
2
3 > After an outage on VDSL last month, I got a backup 10/1 cable
4 > subscription backup. Switching is a bit of a hassle. In addition to
5 > swapping cables, I have to run dhcpcd as root or sudo when swithching
6 > from VDSL to cable. Switching back I have to run "dhcpcd -x", copy over
7 > my backup of /etc/resolve.conf, and run "/etc/init.d/net.eth0 restart".
8 >
9 > The VDSL router/modem offers dhcp and static address space at
10 > 192.168.1.0/24, DNS and default GW 192.168.1.1. I've bought a router
11 > that gets a WAN address from the cable modem via dhcpcd, and offers dhcp
12 > and static address space at 192.168.10.0/24, DNS and default GW
13 > 192.168.10.1. My current /etc/conf.d/net is...
14 >
15 > mtu_eth0="1466"
16 > config_eth0="
17 > 192.168.1.249/24 broadcast 192.168.1.255"
18 > routes_eth0="
19 > default via 192.168.1.1 metric 20
20 > 192.168.1.240/28 via 192.168.1.1 metric 0"
21 >
22 > ...for my machine 192.168.1.249. Can I have something like...
23 >
24 > mtu_eth0="1466"
25 > config_eth0="
26 > 192.168.1.249/24 broadcast 192.168.1.255
27 > 192.168.10.249/24 broadcast 192.168.1.255"
28 > routes_eth0="
29 > default via 192.168.1.1 metric 20
30 > 192.168.1.240/28 via 192.168.1.1 metric 0"
31 >
32
33 For secondary IPs use eth0:0 as the interface name;
34 # ifconfig bond1
35 bond1: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500
36 inet 192.168.1.252 netmask 255.255.255.0 broadcast 192.168.1.255
37 ether aa:86:b3:f6:ee:97 txqueuelen 1000 (Ethernet)
38 RX packets 647891 bytes 867479673 (827.2 MiB)
39 RX errors 0 dropped 0 overruns 0 frame 0
40 TX packets 337624 bytes 114478897 (109.1 MiB)
41 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
42
43 # ifconfig bond1:0 192.168.10.249/24
44 # ifconfig bond1:0
45 bond1:0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500
46 inet 192.168.10.249 netmask 255.255.255.0 broadcast 192.168.10.255
47 ether aa:86:b3:f6:ee:97 txqueuelen 1000 (Ethernet)
48
49 For the routes, your eth0:0 interface will of course need to use
50 192.168.10.1
51
52 However, if you just have a PC with a single interface, and you are going
53 to just manually plug in which ever router you want to use, then just use
54 dhcp on eth0, and plug/replug the cable. The loss of link on the cable
55 should cause dhcp to DISCOVER again, and then get the correct IP and
56 gateway - so no changes will be required on the PC (assuming i understand
57 your setup correctly)