-From a05247037a5d7be34d6df83411df08fe0f176210 Mon Sep 17 00:00:00 2001
+From 6e10a35b07b7af00d579f9df693e2d4444f62a51 Mon Sep 17 00:00:00 2001
 From: Andrei Gherzan <andrei@resin.io>
 Date: Fri, 20 Apr 2018 13:06:14 +0100
 Subject: [PATCH] Add OS dependent default configuration values

+	instance->config.bindaddr.sin_addr.s_addr = inet_addr("10.114.103.1");
+	instance->config.bindaddr.sin_port = 5313;
 	instance->config.relayaddr.sin_family = AF_INET;
 	instance->config.relayaddr.sin_port = htons(53);
 	instance->config.relay_timeout = 30;
@@ -368,6 +368,15 @@ static int dnsu2t_onenter(parser_section *section)
 static int dnsu2t_onexit(parser_section *section)
 {
 	dnsu2t_instance *instance = section->data;
+	//Force some values that the OS depends on
+	if (instance->config.bindaddr.sin_addr.s_addr != inet_addr("10.114.103.1")) {
+		log_error(LOG_WARNING, "Overwriting `dnsu2t:local_ip` entry: it needs to match OS' iptables configuration.\n");
+		instance->config.bindaddr.sin_addr.s_addr = inet_addr("10.114.103.1");
+	}
+	if (instance->config.bindaddr.sin_port != 5313) {
+		log_error(LOG_WARNING, "Overwriting `dnsu2t:local_port` entry: it needs to match OS' iptables configuration.\n");
+		instance->config.bindaddr.sin_port = 5313;
+	}

 	section->data = NULL;
 	for (parser_entry *entry = &section->entries[0]; entry->key; entry++)
diff --git a/redsocks.c b/redsocks.c
index 9d56f42..0c2ad06 100644
--- a/redsocks.c
+++ b/redsocks.c
@@ -127,7 +127,8 @@ static int redsocks_onenter(parser_section *section)

 	instance->config.relayaddr.sin_family = AF_INET;
 	instance->config.relayaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 	/* Default value can be checked in run-time, but I doubt anyone needs that.
@@ -171,6 +172,16 @@ static int redsocks_onexit(parser_section *section)
 	instance->config.bindaddr.sin_port = htons(instance->config.bindaddr.sin_port);
 	instance->config.relayaddr.sin_port = htons(instance->config.relayaddr.sin_port);

+	// Force some values that the OS depends on
+	if (instance->config.bindaddr.sin_addr.s_addr != inet_addr("10.114.103.1")) {
+		log_error(LOG_WARNING, "Overwriting `redsocks:local_ip` entry: it needs to match OS' iptables configuration.\n");
+		instance->config.bindaddr.sin_addr.s_addr = inet_addr("10.114.103.1");
+	}
+	if (instance->config.bindaddr.sin_port != htons(12345)) {
+		log_error(LOG_WARNING, "Overwriting `redsocks:local_port` entry: it needs to match OS' iptables configuration.\n");
+		instance->config.bindaddr.sin_port = htons(12345);
+	}
+
 	if (instance->config.type) {
 		relay_subsys **ss;
 		FOREACH(ss, relay_subsystems) {
--
2.7.4

