On 09/08/2016 06:56, Anthony K wrote:> On 08/08/16 21:05, Levente Birta wrote: >> >> But how can I add achieve this only with ip route command ... without >> route? >> Can I add this in any config files (ex: route-enp2s0)? >> > Hi Levente. > > The iproute2 man page for each command is rather well documented on > CentOS 7. For instance, to view the specifics of *ip route*, type *man > ip-route*. On older versions of CentOS, all commands to ip have been > lumped into *m**an ip*. > > Also, would you care to explain why you'd want to have the same subnet > on 2 interfaces of the same device? If both networks had a host with > the same IP, and another host on either one of the networks needed to > talk to one of them, how would the router know which one to talk to? > > I have encountered this before where one company acquired another and > they both had same subnet IP's. Before we renumbered one of the > subnets, we resolved this via iptables mungling and policy routing. So, > it's doable, but why when there's plentiful supply of RFC1918 IP addresses? >As I said in the initial message the centos box need to access the internet on both interfaces, the gateway in function of source IP ( the two IPs allocated on the centos box on two interfaces ) route the traffic on different WAN connection. My problem simply is that on the Centos box I cannot access the internet on the second interface (i.e. second WAN connection) without the command: #route add default gw 192.168.1.1 dev enp3s0 I'd like to mention that any traffic on the LAN is going in/out on the right interface ... just the internet cannot be reached on the second interface. What I don't understand why the route command allow to add a second default gateway with different interface, but the ip route command doesn't? Thanks -- Levi
On Tue, Aug 09, 2016 at 10:58:40AM +0300, Levente Birta wrote:> What I don't understand why the route command allow to add a second default > gateway with different interface, but the ip route command doesn't?You can only have one default gateway. It sounds to me like you want to use both interfaces, which are both on the same subnet and would connect to the same gateway, as some sort of load-balanced network, where traffic is evenly distributed across both interfaces? Or did I mis-read your initial question? -- Jonathan Billings <billings at negate.org>
On 09/08/2016 15:47, Jonathan Billings wrote:> On Tue, Aug 09, 2016 at 10:58:40AM +0300, Levente Birta wrote: >> What I don't understand why the route command allow to add a second default >> gateway with different interface, but the ip route command doesn't? > You can only have one default gateway. > > It sounds to me like you want to use both interfaces, which are both > on the same subnet and would connect to the same gateway, as some sort > of load-balanced network, where traffic is evenly distributed across > both interfaces? Or did I mis-read your initial question? >No, there is no load-balancing.... It is a server on the LAN with two NICs, two IPs and I want to access the internet on both interfaces ... which means, practically, different WAN connection, but from the server's point of view doesn't matter, the routing to different WAN is a job of gateway's. And as I said in the initial message I achieved this ... :) The question is how can I achieve this with more elegant way, because the "route" command is deprecated anyway. So, again: Centos 7 2 NICs enp2s0-192.168.1.12 enp3s0-192.168.1.13 default gateway on enp2s0 is 192.168.1.1, defined in /etc/sysconfig/network Which other way (preferred with "ip route") can I add this, but: #route add default gw 192.168.1.1 dev enp3s0 ???? Thanks Levi