Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Dhcpd: how to set gateway none to a specific client

    Scheduled Pinned Locked Moved DHCP and DNS
    12 Posts 4 Posters 950 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tonysud
      last edited by

      I don't want to send localhost as gateway/dns

      I haven't understood if it's possibile to avoid sending gateway/dns to a specific client with ISC dhcpd or it's an upstream limitation

      1 Reply Last reply Reply Quote 0
      • johnpozJ
        johnpoz LAYER 8 Global Moderator
        last edited by

        its not possible in the gui currently.. If you want it to be possible in the gui - then request that feature.  But you can always modify the conf file directly… Your problem being is that would be reset on reboot, upgrade of pfsense, etc.

        You have been given multiple ways to accomplish the task.  So here are you options.

        Send loopback to the client for gateway and dns via dhcpd gui
        Edit the conf file directly not to send.
        Edit the client directly and do not use dhcpd - and don't set gateway or dns
        Send it the gateway info and dns, and then just block it firewall from actually using the gateway for anything you don't want it to go to, all if that is what you want.  If handing pfsense as dns to the client you can just block the client at the firewall rules from actually getting to pfsense for dns.

        Those are you options until after the options has been added to the gui, if ever.

        Put in the feature request and wait for pfsense dev to do it
        Put in a bounty request to get someone else to do it.
        Write the code yourself and submit it, or use it on your own local install.

        Does that answer all your possible questions?

        One more option - run yoru dhcpd on something else that allows you to not send gateway and or dns to clients you don't want to send it too.

        In your conf for your specific pool or client that you dont want to send gateway remove

        option routers
        option domain-name-servers

        from that section of the conf.

        /var/dhcpd/etc/dhcpd.conf

        You could always create your own dhcpd.conf.custom file and have dhcpd load that conf vs the default one, etc.

        An intelligent man is sometimes forced to be drunk to spend time with his fools
        If you get confused: Listen to the Music Play
        Please don't Chat/PM me for help, unless mod related
        SG-4860 24.11 | Lab VMs 2.8, 24.11

        1 Reply Last reply Reply Quote 0
        • GrimsonG
          Grimson Banned
          last edited by

          There is one more option for the default gateway, but it's only usefull if you want a "whitelist" kind of approach:

          Set the gateway to "none" in the global config, then add static leases, with the actual gateway, for all devices that should receive it.

          1 Reply Last reply Reply Quote 0
          • johnpozJ
            johnpoz LAYER 8 Global Moderator
            last edited by

            Good point Grimson - missed that one ;)

            An intelligent man is sometimes forced to be drunk to spend time with his fools
            If you get confused: Listen to the Music Play
            Please don't Chat/PM me for help, unless mod related
            SG-4860 24.11 | Lab VMs 2.8, 24.11

            1 Reply Last reply Reply Quote 0
            • T
              tonysud
              last edited by

              Edit the conf file directly not to send.

              :-
              I don't understand which directive to use

              my dhcpd.conf (generated by pfsense) is like this

              subnet 192.168.0.0 netmask 255.255.0.0 {
              pool {
              option domain-name-servers 192.168.0.88,151.99.0.100,151.99.125.1;
              ignore-client-uids true;

              range 192.168.2.200 192.168.2.240;
              }

              option routers 192.168.2.1;
              option domain-name-servers 192.168.0.88,151.99.0.100,151.99.125.1;

              }

              host s_lan_0 {
                      hardware ethernet 00:25:22:19:0a:74;
              fixed-address 192.168.2.8;
              }

              I want to patch it
              what to add inside host s_lan_0 to prevent giving gateway and dns?

              1 Reply Last reply Reply Quote 0
              • johnpozJ
                johnpoz LAYER 8 Global Moderator
                last edited by

                So here is that host I handed loopback in mine

                host s_lan_3 { 
                        hardware ethernet 00:0c:29:85:7d:0a;
                        fixed-address 192.168.9.14;
                        option routers 127.0.0.1;
                        option domain-name-servers 127.0.0.1;
                }

                See how it has the option routers and dns… Just don't put anything in those options.  But leave the options in there.

                So

                host s_lan_3 { 
                        hardware ethernet 00:0c:29:85:7d:0a;
                        fixed-address 192.168.9.14;
                        option routers ;
                        option domain-name-servers ;
                }

                Should work - have not actually tested that... But that is what I would do, or atleast try first.  Have not had to edit a dhcpd.conf by hand in many many years ;)

                An intelligent man is sometimes forced to be drunk to spend time with his fools
                If you get confused: Listen to the Music Play
                Please don't Chat/PM me for help, unless mod related
                SG-4860 24.11 | Lab VMs 2.8, 24.11

                1 Reply Last reply Reply Quote 0
                • T
                  tonysud
                  last edited by

                  @johnpoz:

                  option routers ;

                  Configuration file errors encountered – exiting

                  It doesn't work :(

                  1 Reply Last reply Reply Quote 0
                  • JKnottJ
                    JKnott
                    last edited by

                    I assume the intent is to keep that device from reaching the Internet.  Why not assign it's MAC a specific IP address and then block that address from reaching the 'net?

                    PfSense running on Qotom mini PC
                    i5 CPU, 4 GB memory, 32 GB SSD & 4 Intel Gb Ethernet ports.
                    UniFi AC-Lite access point

                    I haven't lost my mind. It's around here...somewhere...

                    1 Reply Last reply Reply Quote 0
                    • T
                      tonysud
                      last edited by

                      for example one machine has three network cards and has already a default gateway on another card
                      I want to give only ip and netmask to avoid problem

                      1 Reply Last reply Reply Quote 0
                      • johnpozJ
                        johnpoz LAYER 8 Global Moderator
                        last edited by

                        Well that sort of setup is pretty borked already if you ask me…

                        But anyway - I tested this.. And its not left blank just use none..  As I said I had not had to edit a dhcpd.conf in a while directly..

                        So I edited that test host I was playing with to show you loopback..

                        So I killed dhdpd with killall -3 dhcpd

                        I then edited the dhcpd.conf

                        I then restarted it.. from cmd line.. you can find your start command with..

                        ps axww | grep dhcpd

                        You could always create a file that does this for you and have it auto start in rc.d that loads your specific conf.. Once you do stuff like this the gui is going to overwrite stuff, etc..

                        Anyway you can see I edited so its none; for your routers and dns.

                        Then started dhcpd.. I then did a release and renew on that client.  You can see that it had loopback, then when I had it get a new lease it got nothing for gateway and dns.  I sniffed this traffic and you can see in the offer that router and dns was not even in the offer.

                        edit:  This is a hack of a work around for sure.. I would suggest you put in a feature request on redmine to allow for none on the dhcp reservation screens.. Since it clearly takes that value as input.

                        dhcpnone.png
                        dhcpnone.png_thumb

                        An intelligent man is sometimes forced to be drunk to spend time with his fools
                        If you get confused: Listen to the Music Play
                        Please don't Chat/PM me for help, unless mod related
                        SG-4860 24.11 | Lab VMs 2.8, 24.11

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.