# /etc/conf.d/net and routes

## systema encephale

Hi,

I need to assign an IP address to an eth interface on a Gentoo box but I want all the traffic for the given network to go through the default gateway. When I write the network config in /etc/conf.d/net and restart the net.eth0 daemon, besides configuring that address on the eth0, it also sets the direct route for that network. Well, I don't want it to set the route. Is there a way to tell Gentoo "just do the ifconfig stuff and don't touch routes"?

Thanks a lot

----------

## AngelKnight

[quote="systema encephale"]Hi,

I need to assign an IP address to an eth interface on a Gentoo box but I want all the traffic for the given network to go through the default gateway. When I write the network config in /etc/conf.d/net and restart the net.eth0 daemon, besides configuring that address on the eth0, it also sets the direct route for that network. Well, I don't want it to set the route. Is there a way to tell Gentoo "just do the ifconfig stuff and don't touch routes"?

Thanks a lot[/quote]

If you're assigning statically, set the network on the IP address to a /32 instead of whatever it actually is.  But you're going to have to add a connected route for your gateway also so that your Gentoo box knows it can ARP for it.  Unless it can't, in which case you're going to have a fun time with this :)

Background: If you add, say, a /24 address, that's an assertion that other IPs on that /24 are "directly connected" to the ethernet adapter.  On ethernet or ethernet-alikes, that means the station can ARP for the destination L3 right on the ethernet device.  If you were to add the /XX address, the kernel would automatically add the connected route in the background.  If you have ECMP configured, you can see this, I beileve, with "/sbin/ip route show table 255".

----------

## systema encephale

Hi, thanks for the reply. I will explain you my situation so that you can understan better. I want to split up my huge /16 network to several /24 smaller ones using different vlans. In the center there's an HP Procurve 4204 doing basic layer 3 routing between the vlans. My Gentoo box has a foot on each vlan and will work as dhcp AND http server: this means that the http server address MUST be the same for all vlans, while the dhcp server address has to belong to the subnet it releases addresses for, otherwise the dhcpcd daemon complains at startup.

Let's say my box has main address 10.0.0.100/24 and 101 vlan's address 10.2.1.253/24 (10.2.1.254 is the procurve's address). It can release addresses to hosts in the 101 vlan, but if one of them (say 10.2.1.1) tries to contact 10.0.0.100 the reply comes from 10.2.1.253 and gets discarded. 10.0.0.100 and 10.2.1.253 are the same machine, but the reply packet goes through the shortest route. If I remove from the routing table the 10.2.1.0/24 direct route and I force the Gentoo box to go through its default gateway (again, the procurve) the 10.2.1.1 host sees the reply coming from 10.0.0.100.

Do you have another solution? Should I play with metric?

Thanks

----------

## gerdesj

One simple solution might be to remove the additional links on your Gentoo box ie only have one IP address on it.  Then use BOOTP/DHCP forwarding on your Procurve to get requests for addresses to your DHCP server.  The Procurve is your router so it should worry about what network is where.  dhcpd will still allocate addresses for the correct subnet because the forwarding agent will describe the network it got the request for.

Another idea might be to use policy based routing on your Gentoo box to do source based routing but that's a bit of a fiddle.  Read these:

http://www.policyrouting.org/PolicyRoutingBook/ONLINE/TOC.html

http://lartc.org/howto/

Cheers

Jon

----------

## AngelKnight

 *systema encephale wrote:*   

> Hi, thanks for the reply. I will explain you my situation so that you can understan better. I want to split up my huge /16 network to several /24 smaller ones using different vlans. In the center there's an HP Procurve 4204 doing basic layer 3 routing between the vlans. My Gentoo box has a foot on each vlan and will work as dhcp AND http server: this means that the http server address MUST be the same for all vlans, while the dhcp server address has to belong to the subnet it releases addresses for, otherwise the dhcpcd daemon complains at startup.
> 
> Let's say my box has main address 10.0.0.100/24 and 101 vlan's address 10.2.1.253/24 (10.2.1.254 is the procurve's address). It can release addresses to hosts in the 101 vlan, but if one of them (say 10.2.1.1) tries to contact 10.0.0.100 the reply comes from 10.2.1.253 and gets discarded. 10.0.0.100 and 10.2.1.253 are the same machine, but the reply packet goes through the shortest route. If I remove from the routing table the 10.2.1.0/24 direct route and I force the Gentoo box to go through its default gateway (again, the procurve) the 10.2.1.1 host sees the reply coming from 10.0.0.100.
> 
> Do you have another solution? Should I play with metric?
> ...

 

If you insist on doing this on one box, your only likely means of accomplishing this is either policy routing at your web-and-DHCP server, or teaching your procurve to do exceedingly twisted things to all the traffic it manages.

If you insist on DHCP and web on the same server, these are the choices your constraints have left you with.

----------

