Possible default gateway bug in DHCP



  • Looks to affect 2.1.2, not sure about 2.1.1 but I'd assume so.
    Just checked, affects 2.1-release as well. Not sure how many versions back this bug goes.

    Steps to reproduce:
    1. Change WAN interface to a static IP
    2. Set LAN DHCP range, don't set the gateway, save
    4. Release and renew lease on client
    5. Check routing table, no default gateway.

    I'm not sure where this issue is stemming from, but am looking into it. If anyone can confirm they can reproduce, it'd be appreciated. This seems to be a pretty huge bug.

    Edit: quick fix for this specific scenario (I'm assuming not ideal, so don't make this change unless you really don't want to put in a gateway), edit /etc/inc/services.inc. Go to line 707. The block starts out like this:

        703                 if ($dhcpifconf['gateway']) {
        704                         $routers = $dhcpifconf['gateway'];
        705                         $add_routers = true;
        706                 } else {
        707                         $routers = $ifcfgip;
        708                 }
    
    

    and should end up looking like this:

        703                 if ($dhcpifconf['gateway']) {
        704                         $routers = $dhcpifconf['gateway'];
        705                         $add_routers = true;
        706                 } else {
        707                         $add_routers = true;
        708                         $routers = $ifcfgip;
        709                 }
    
    

    Again, not ideal, do this at your own risk, etc., but this gets the correct behavior when no gateway is specified.


  • Rebel Alliance Developer Netgate

    Make sure you have a gateway selected on your WAN (Interfaces > WAN) and NO gateway set on Interfaces > LAN.

    It works with a proper configuration, that is a very common setup that we perform constantly.



  • Interesting. Why is a default gateway on the WAN interface required to serve a default gateway for the LAN interface though?


  • Rebel Alliance Developer Netgate

    Selecting a gateway on the WAN marks it as a WAN-type interface to pfSense.

    With no WAN-type interfaces, DHCP will act as though the unit is NOT a gateway to reach the Internet as it has no WAN-type interfaces.



  • DHCP isn't always simply a gateway to reach the internet though, many companies will have a completely locked down set of networks that still require routing to happen, which requires default gateways on clients. It's not as big of an issue as I thought initially, but it does seem, to me, like pretty unexpected behavior. Having DHCP only hand out a gateway if there's a default gateway on the router itself is behavior I've never seen on any other equipment, personally.


  • Rebel Alliance Developer Netgate

    Your case is the minority, and though it isn't covered automatically, you can do so manually. There's no bug or problem here.



  • Hi Jim,

    I got stuck in this problem using 2.1.5 amd64. I have Quagga OSPFd to set routes, so I have no gateways set by me or dhcp. So I got the issue above, when a client uses dhcp to get IP's and stuff, no default gw is set. This is only fixed when I say there the gw address on dhcpd page. This is not good for me. I tested this on 2.1 amd64, and it behaved differently. It sends the gw IP.

    this is expected and I must workaround it ?

    thanks,

    none


  • Rebel Alliance Developer Netgate

    For your uncommon edge case, yes, you must manually enter the gateway IP that you want in the DHCP settings.

    If pfSense has no knowledge of a gateway in its config, it can't know that it's capable of acting as a gateway in that role, so you must manually fill in the setting. There is no viable way to detect your case compared to someone who intentionally didn't set a gateway because they didn't want pfSense to act as a gateway.



  • Ok Jim,

    did it and is ok. Thanks for the answer :)

    This was really changed from 2.1 to now ?

    att,

    none


  • Rebel Alliance Developer Netgate

    AFAIK it's been that way forever (Or at least back to the 1.2.x days).


Log in to reply