LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Two NIC Setup - Unable to route via one of them. (https://www.linuxquestions.org/questions/linux-networking-3/two-nic-setup-unable-to-route-via-one-of-them-4175460042/)

compix 04-29-2013 01:26 PM

Two NIC Setup - Unable to route via one of them.
 
Hi Folks,

I am not a network expert but not a newbie either, I am having an interesting issue.

I have just setup a machine which got two NICs, one for private network and the other one for public network which has a real IP assigned to it.

Configuration of eth0 for private network as follows;

Code:

DEVICE=eth0
HWADDR=XXX
TYPE=Ethernet
UUID=XXX
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=172.26.111.131
NETMASK=255.255.255.128
GATEWAY=172.26.111.129

Configuration of eth1 for public network as follows;

Code:

DEVICE=eth1
HWADDR=XXX
TYPE=Ethernet
UUID=XXX
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=PUBLIC_IP
NETMASK=255.255.255.248
GATEWAY=PUBLIC_GATEWAY

Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
default        PUBLIC_GATEWAY  0.0.0.0        UG    0      0        0 eth1
PUBLIC_NETWORK_ID  *              255.255.255.248 U    0      0        0 eth1
link-local      *              255.255.0.0    U    1002  0        0 eth0
link-local      *              255.255.0.0    U    1004  0        0 eth1
172.26.111.128  *              255.255.255.128 U    0      0        0 eth0

I am sure this is quite easy to achieve. I have searched about this, tried lots of ways(tried using route file, command) but somehow could not get this working. The machine still tries to route private IPs via public gateway.

I would appreaciate any ideas on this. Where I am wrong at?

TIA.

KinnowGrower 04-29-2013 09:11 PM

It is not clear what you want to achieve?. Can you clarify?

compix 04-30-2013 03:43 AM

Hi KinnowGrower,

I just want to be able to access 172.26.111.128/25 via eth0. At this time, with this setup, I even cannot ping gateway.

Thanks.

coal-fire-ice 04-30-2013 03:16 PM

The private network has a gateway between your system and the other hosts on the private segment? If you're sure it does perhaps we need more info. Otherwise:

I'm not 100% familiar with the centos method of configuring networks, but in debian based systems to achieve what you describe i would omit the gateway entry of the private network config as it will confuse the routing, especially if that gateway doesn't lead out onto the wider internet. Assuming your system's private nic is on the same subnet (172.26.111.129-254 i assume) as the systems you are trying to talk to there is no requirement for a gateway because all hosts should be able to talk directly to each other via a switch or such (unless your actual situation is more complex than that you describe).


If there really is a gateway - well - normally gateways are used to bridge networks, i.e. a gateway would be between your internal network and the external network (internet) - To quote wikipedia:
Quote:

On an IP network, clients should automatically send IP packets with a destination outside a given subnet mask to a network gateway. A subnet mask defines the IP range of a private network. For example, if a private network has a base IP address of 192.168.0.0 and has a subnet mask of 255.255.255.0, then any data going to an IP address outside of 192.168.0.X will be sent to that network's gateway. While forwarding an IP packet to another network, the gateway might or might not perform Network Address Translation.
Anyway, hope the info helps. If you want to discuss, pm me and we can sort something out.

compix 04-30-2013 05:19 PM

Quote:

Originally Posted by coal-fire-ice (Post 4942144)
The private network has a gateway between your system and the other hosts on the private segment? If you're sure it does perhaps we need more info. Otherwise:

I'm not 100% familiar with the centos method of configuring networks, but in debian based systems to achieve what you describe i would omit the gateway entry of the private network config as it will confuse the routing, especially if that gateway doesn't lead out onto the wider internet. Assuming your system's private nic is on the same subnet (172.26.111.129-254 i assume) as the systems you are trying to talk to there is no requirement for a gateway because all hosts should be able to talk directly to each other via a switch or such (unless your actual situation is more complex than that you describe).


If there really is a gateway - well - normally gateways are used to bridge networks, i.e. a gateway would be between your internal network and the external network (internet) - To quote wikipedia:


Anyway, hope the info helps. If you want to discuss, pm me and we can sort something out.

Thanks very much for the thoughts!

LOL, this all was my fault. I was trying to ping/trace a host that indeed does not exist at all. No IP was assigned to router's interface and I was trying to ping that IP which supposed to be the IP of router and was thinking as if the machine was not routing the packets properly. :)

Here's some personal explanation;

I was trying to get this internal gateway working because I was trying to get this machine communicating with other internal subnets(different) inside a large internal network. However, after all these I now understand this better. Static routes are what we need in such situations. No need for a second gateway for the second interface - instead, a static route can be defined to route specific subnets via a specific router as long as the machine itself has an IP inside that subnet(the subnet where router resides).

But I think it would be better to have an option to have a second gateway with a higher metric for redundancy? I am sure this can be achieved with some work arounds but not sure if Linux supports this natively?

Lessons learned.

Thanks everyone! :)


All times are GMT -5. The time now is 03:23 AM.