.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 11, 2017
+.Dd May 9, 2017
.Dt DHCPCD 8
.Os
.Sh NAME
.Nm
from touching your DNS settings you would do:-
.D1 dhcpcd -C resolv.conf eth0
+.It Fl G , Fl Fl nogateway
+Don't set any default routes.
.It Fl H , Fl Fl xidhwaddr
Use the last four bytes of the hardware address as the DHCP xid instead
of a randomly generated number.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 24, 2017
+.Dd May 9, 2017
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
.It Ic nodhcp6
Don't start DHCPv6 or listen to DHCPv6 messages.
Normally DHCPv6 is started by a RA instruction or configuration.
+.It Ic nogateway
+Don't install any default routes.
+.It Ic gateway
+Install a default route if available (default).
.It Ic nohook Ar script
Don't run this hook script.
Matches full name, or prefixed with 2 numbers optionally ending with
#define O_IPV6 O_BASE + 33
#define O_CONTROLGRP O_BASE + 34
#define O_SLAAC O_BASE + 35
-// unused O_BASE + 36
+#define O_GATEWAY O_BASE + 36
#define O_NOUP O_BASE + 37
#define O_IPV6RA_AUTOCONF O_BASE + 38
#define O_IPV6RA_NOAUTOCONF O_BASE + 39
{"nodhcp6", no_argument, NULL, O_NODHCP6},
{"controlgroup", required_argument, NULL, O_CONTROLGRP},
{"slaac", required_argument, NULL, O_SLAAC},
+ {"gateway", no_argument, NULL, O_GATEWAY},
{"reject", required_argument, NULL, O_REJECT},
{"bootp", no_argument, NULL, O_BOOTP},
{"nodelay", no_argument, NULL, O_NODELAY},
return -1;
}
break;
+ case 'G':
+ ifo->options &= ~DHCPCD_GATEWAY;
+ break;
case 'H':
ifo->options |= DHCPCD_XID_HWADDR;
break;
ctx->control_group = grp->gr_gid;
#endif
break;
+ case O_GATEWAY:
+ ifo->options |= DHCPCD_GATEWAY;
+ break;
case O_NOUP:
ifo->options &= ~DHCPCD_IF_UP;
break;
/* Seed our default options */
if ((ifo = default_config(ctx)) == NULL)
return NULL;
- ifo->options |= DHCPCD_DAEMONISE;
+ ifo->options |= DHCPCD_DAEMONISE | DHCPCD_GATEWAY;
#ifdef PLUGIN_DEV
ifo->options |= DHCPCD_DEV;
#endif
/* Don't set any optional arguments here so we retain POSIX
* compatibility with getopt */
#define IF_OPTS "146bc:de:f:gh:i:j:kl:m:no:pqr:s:t:u:v:wxy:z:" \
- "ABC:DEF:HI:JKLMNO:PQ:S:TUVW:X:Z:"
+ "ABC:DEF:GHI:JKLMNO:PQ:S:TUVW:X:Z:"
#define NOERR_IF_OPTS ":" IF_OPTS
#define DEFAULT_TIMEOUT 30
#define DHCPCD_ARP (1ULL << 0)
#define DHCPCD_RELEASE (1ULL << 1)
// unused (1ULL << 2)
-// unused (1ULL << 3)
+#define DHCPCD_GATEWAY (1ULL << 3)
#define DHCPCD_STATIC (1ULL << 4)
#define DHCPCD_DEBUG (1ULL << 5)
#define DHCPCD_LASTLEASE (1ULL << 7)
assert(nrt != NULL);
ctx = nrt->rt_ifp->ctx;
+ /*
+ * Don't install a gateway if not asked to.
+ * This option is mainly for VPN users who want their VPN to be the
+ * default route.
+ * Because VPN's generally don't care about route management
+ * beyond their own, a longer term solution would be to remove this
+ * and get the VPN to inject the default route into dhcpcd somehow.
+ */
+ if (((nrt->rt_ifp->active &&
+ !(nrt->rt_ifp->options->options & DHCPCD_GATEWAY)) ||
+ (!nrt->rt_ifp->active && !(ctx->options & DHCPCD_GATEWAY))) &&
+ sa_is_unspecified(&nrt->rt_dest) &&
+ sa_is_unspecified(&nrt->rt_netmask))
+ return false;
+
rt_desc(ort == NULL ? "adding" : "changing", nrt);
change = false;