You are not logged in.

#1 2013-02-09 02:30:52

srf21c
Member
Registered: 2012-04-16
Posts: 24

Use netcfg to force one default route when two interfaces use DHCP

I'm using netcfg to configure a server with two network interfaces, one public and one private. Both interfaces are configured via DHCP. The internal one via a home router, and the external one via the ISP's DHCP server.

The problem I'm having is that there are two default routes, and the one with the lower metric is the private interface. Thus all Internet traffic leaves via the home router instead of the public Internet connected interface on the server. I want all Internet bound traffic on the server to leave directly via the server's public interface.

If I manually delete the extra default route using the command "ip route delete default via 192.x.x.x dev enp3s6 metric 202", it comes back automatically. I assume this route is restored when the private interface refreshes the DHCP lease.

I've searched the Arch wiki, forums and mailing list. I did find a post on the forum that solves almost the same issue.  In the environment in question however, DHCP is preferred for configuring all LAN hosts whenever possible.

I'll post copies of my /etc/con.d/netcfg and /etc/network.d/lan0-profile and /etc/network.d/wan0-profile files.

Going to dig into the git docs here as well to see if I can find any solutions.

Last edited by srf21c (2013-02-09 17:06:15)

Offline

#2 2013-02-09 06:49:53

t0m5k1
Member
From: overthere
Registered: 2012-02-10
Posts: 324

Re: Use netcfg to force one default route when two interfaces use DHCP

could you not adjust the dhcp config to provide a static configuration to the private interface with no default gateway OR change the private interface from dhcp to static & omit the default gateway.

I used to use this setup on my desktop at work so I could test/configure routers


ROG Strix (GD30CI) - Intel Core i5-7400 CPU - 32Gb 2400Mhz - GTX1070 8GB - AwesomeWM (occasionally XFCE, i3)

If everything in life was easy, we would learn nothing!
Linux User: 401820  Steam-HearThis.at-Last FM-Reddit

Offline

#3 2013-02-09 07:23:14

srf21c
Member
Registered: 2012-04-16
Posts: 24

Re: Use netcfg to force one default route when two interfaces use DHCP

t0m5k1 wrote:

could you not adjust the dhcp config to provide a static configuration to the private interface with no default gateway

I'm not sure this can be accomplished using the reservation options exposed via the pfsense web interface which provides DHCP services to the LAN.

I might be able to create a reservation and then manually edit the corresponding pfsense xml configuration file to create a lease which does not assign a gateway.

t0m5k1 wrote:

OR change the private interface from dhcp to static & omit the default gateway.

Of course, however the goal is to use DHCP configuration for both internal and external interfaces. Otherwise the solution detailed in the referenced forum post would have sufficed.

t0m5k1 wrote:

I used to use this setup on my desktop at work so I could test/configure routers

Care to share the DHCP options and or config that was used?

Offline

#4 2013-02-10 15:12:23

t0m5k1
Member
From: overthere
Registered: 2012-02-10
Posts: 324

Re: Use netcfg to force one default route when two interfaces use DHCP

srf21c wrote:
t0m5k1 wrote:

I used to use this setup on my desktop at work so I could test/configure routers

Care to share the DHCP options and or config that was used?

at work we were assigned IP Addrs via a windows server, my workstation @ that time was ubuntu & I just opened NetworkManager, opened the edit screen for my test connection, changed it from auto to static, gave it the IP I wanted/netmask, clicked the routes button & placed a tick in the check box to "use this connection only for resources on its network"

I use pfsense at home & unfortunately this cannot be done at all reservations inherit the system configured ip address as the default gateway
REF: http://forum.pfsense.org/index.php?topic=58000.0

I am wondering though if you could create an internal firewall redirect rule to point the traffic from the relevant IP to the 2nd gateway!


ROG Strix (GD30CI) - Intel Core i5-7400 CPU - 32Gb 2400Mhz - GTX1070 8GB - AwesomeWM (occasionally XFCE, i3)

If everything in life was easy, we would learn nothing!
Linux User: 401820  Steam-HearThis.at-Last FM-Reddit

Offline

#5 2013-02-10 21:56:38

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Use netcfg to force one default route when two interfaces use DHCP

I've not used it, but I always assumed that this was the sort of situation that could be fixed using ip routes?
You should be able to assign an address range to a device, from a quick look at the "ip-route" man page.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#6 2013-02-11 00:50:02

srf21c
Member
Registered: 2012-04-16
Posts: 24

Re: Use netcfg to force one default route when two interfaces use DHCP

I think I might have found the solution via a doc in the git repo

In theory, if I just place the wan0-profile first in the NETWORKS= statement of /etc/conf.d/netcfg, that interface should be brought up first and thus have the lower route metric, yielding the desired traffic flow.

The additional default route through the lan interface would not be a problem then, as it would only kick in when the public interface was unavailable, desirable from a fault tolerance standpoint.

Here's a snip of the relevant section of the git project doc:

Start a specific list of profiles on boot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net-profiles allows you to start some profiles at boot time. Specify the
profiles you want netcfg to start (in the order you want them to be
started) in the +NETWORKS+ line in '/etc/conf.d/netcfg'.
Prefix a profile with a `@' to start it in the background. For example:

--------------------------------
NETWORKS=(@adsl @mywireless lan)
--------------------------------

Offline

#7 2013-02-19 07:27:09

srf21c
Member
Registered: 2012-04-16
Posts: 24

Re: Use netcfg to force one default route when two interfaces use DHCP

I ended up abandoning netcfg in favor of netctl

netctl solved the problems netcfg was having starting both network profiles under systemd.

I'm currently trying to figure out how to configure multiple default routes in linux using this blog post

It involves editing /etc/iproute2/rt_tables to add a custom table, then running some other ip route commands to ensure that traffic leaves on the same interface it arrived on.

Last edited by srf21c (2013-02-20 23:55:13)

Offline

Board footer

Powered by FluxBB