Centos 7 - Router and Failover

Issues related to configuring your network
Post Reply
shamuel
Posts: 5
Joined: 2014/10/08 20:34:19

Centos 7 - Router and Failover

Post by shamuel » 2014/10/08 20:51:34

Hello

I need configure a centos server like a router and Failover

I have two ISP, but they are dynamic IP address
The first ISP is on 'enp4s0' interface and the second ISP is on 'enp4s1' interface, the LAN card is on 'enp2s0'.
I found many posts to centos as a router and failover but no one is about configure dynamic IP address.

How can I set the LAN gateway in this scenery, I think probably I need made some script, but I don't know.

ps: I have not routers, just the modems.

Could anyone help me?

Thanks you!

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Centos 7 - Router and Failover

Post by aks » 2014/10/09 16:10:31

Well you need to decide how you're going to handle the IP address changes (which in theory could happen at any time). Then you need to decide on router failover. There are boat loads of ways of doing failover - I personally like VRRP. This is a little off topic (being a CentOS forum) but you could have a look at something like http://www.keepalived.org/

Hope that helps.

shamuel
Posts: 5
Joined: 2014/10/08 20:34:19

Re: Centos 7 - Router and Failover

Post by shamuel » 2014/10/09 18:49:04

Thank you aks
I appreciate your suggestion about VRRP to failover.

Guys,
On CentOS, Can I set the gateway to an interface name or just to ip address?

Thank you

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Centos 7 - Router and Failover

Post by aks » 2014/10/10 16:07:53

Layer 3 (networking) is IP address. You can't IP route across an interface.

shamuel
Posts: 5
Joined: 2014/10/08 20:34:19

Re: Centos 7 - Router and Failover

Post by shamuel » 2014/10/20 15:36:20

Thats make sense aks, thank you for reply.
I ask this because that link (https://www.centos.org/docs/5/html/5.2/ ... twork.html) show an option called gateway_dev, I wanna understand if is possible do some script to manage this option in my scenary.

Just to complement, I know in routers cisco we can use "ip route 0.0.0.0 0.0.0.0 s0/0" (where that make a static route to internet through interface serial0/0) to redirect outside traffic.
My idea is do the same in CentOS, but in this multihomed scenary.

Best regards,
Samuel Almeida

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Centos 7 - Router and Failover

Post by aks » 2014/10/20 16:58:10

Okay I can't find any mention of gateway_dev in the link you provided.

So using Cisco IOS command ("ip route 0.0.0.0 0.0.0.0 s0/0") to set the default gateway, a similar thing can be done in CentOS via the ip route command. Is that all you want? I'm a little confused, so perhaps an example might work:

Let's say I have three interfaces (call them eth0, eth1 and eth2). Each interface has an IP address. Because it has an IP address, it will have a subnet and network address, this is how routing is done.

So if we have:
eth0 with the address 192.168.0.254/24, all packets destined to the address 192.168.0.0-255 will go to eth0.
eth1 with the address 192.168.1.254/24, all packets destined to the address 192.168.1.0-255 will go to eth1.
eth2 with the address 192.168.2.254/24,all packets destined to the address 192.168.1.0-255 will go to eth2.
Additionally you can have a default gateway address, which means if a packet is destined for an unknown network, send it here. So let's add that to the example:
eth0 has the default gateway address of 192.168.0.1/32 (which is the gateway for that subnet), then a packet destined to (say) google with travel via eth0 to the default router.

Make sense?

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Centos 7 - Router and Failover

Post by aks » 2014/10/20 17:08:10

Oops, just relised there is GATEWAYDEV (as opposed to gateway_dev) on that link you provided. Yes you can use it to set a default gateway, but it's not routing over layer 2 interfaces, it's still routing over layer 3 addresses.

You do realise that the whole idea of routing is to have a permanent (i.e.: known) and reachable addresses? Perhaps a way around that is to abstract the network. Have a node (maybe with HA clustering for resiliency) to be the thing that connects to the network(s) you don't control and set that as the internal default gateway. Then all other networks can be abstracted from the external network(s). I suppose you could try and do something clever with one of the router protocols (such as RIP, OSPF, ISIS etc.).

There is a "form" of layer 2 routing (although it's never calling routing as routing must by definition be layer 3, so it's bridging), called TRILL. There's also a competitor called TRILL, called SPB. Suggest you google those words (and all they mean!)

Regards

shamuel
Posts: 5
Joined: 2014/10/08 20:34:19

Re: Centos 7 - Router and Failover

Post by shamuel » 2014/10/20 17:26:59

That is the part of site show the gatewaydev (sorry, I put underscore)
28.1.21. /etc/sysconfig/network
.....
GATEWAYDEV=<value>, where <value> is the gateway device, such as eth0. Configure this option if you have multiple interfaces on the same subnet, and require one of those interfaces to be the preferred route to the default gateway.
.....
Yes, make sense!
Sorry for make that confusion, I'll explain the case below:

I have 3 interfaces:
eth0, is IP static 192.168.0.1/24, LAN
eth1, is a client DHCP interface, WAN1
eth2, is a client DHCP interface, WAN2

eth0 configuration (connected to switch)
IP: 192.168.0.1
MASK: 255.255.255.0
GATEWAY: What is the gateway? I have no static IP address in WAN interfaces, I can't set the address of gateway in this section.

eth1 configuration (connected to modem)
IP: Dynamic
MASK: Dynamic
GATEWAY: Dynamic

eth2 configuration (connected to modem)
IP: Dynamic
MASK: Dynamic
GATEWAY: Dynamic

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Centos 7 - Router and Failover

Post by aks » 2014/10/20 19:32:59

Yeah I know that, I can read (well sometimes I can read - depends on the amount of wine:lol:), so I think you're "farting aginst thunder" (that's my speak and should not be taken as offensive - I should copyleft it so others use it more). I think yoiu want to make routing decisions based on upon an unknown adress in some kind of dynamic way. So something like if this (received packet) is from (say 89.86.69.0/16) send it via eth1, if this received packet is from (say) 1.0.9.12/8 send it via eth2, regardless of the the IP addresses on eth1 and eth2.
Is that what you want?

Is that what you want? If it is, that's actually quite complex (so hard) - I know that many times I've thought that would be an easy way to solve a particular problem. In that case you need a way to dynamically update the local IP tables, which is achieveable with a bit of password-less ssh keys and several networking commands, but then you get into a whole bunch of other stuff, like what is my default route when I apply routing table changes? Has the default changed? Yes you can provide that via the networking commnds passed via ssh, but it is complex.

You can only have one default gateway (gateway is another name for router). This is absoluete (within the context of the Internet's RFCs).

So answer the question, what do you want?

You have eth0 with a static address, eth1 and eth2 being dynamic (that could change their addresses at any time), so you want to route (for unknown networks like the Internet) to eth1 and eth2 at the same time? Do you want your clients (are they Linux/UNIX/Mac OS or Winblowz?) to route via eth1 and/or eth2 when they don't know what addresses eth1/2 are (as they are dynamic)? That's very complex and there must be an easier way..... What's the "business case" ( God I hate that phrase, but ther you go)?

shamuel
Posts: 5
Joined: 2014/10/08 20:34:19

Re: Centos 7 - Router and Failover

Post by shamuel » 2014/10/21 11:44:55

LOL....

We are getting the point,

In other words, what I want is use a dynamic routing protocol.
I think the first problem was try solve a problem in wrong path, "I need think out the box!"

Thank you for your assistance aks!

Post Reply