Setting host-uniq for PPPoE
-
My ISP uses the host-uniq part of the PPPoE PADI packet to authenticate the system before any communication. How can I set this value in PfSense?
-
feature request created: https://redmine.pfsense.org/issues/10597
-
thank you for creating a feature request!
Is there someway to do this directly through the shell for now? Do you have any insight on which files I should edit using the shell?
-
@parithosh Can you test this PR https://github.com/pfsense/pfsense/pull/4337 ?
patch id 7a6a322bf1d6208847722e9a91a6397e266b4d87 -
Hey!
Unfortunately I can't connect to the internet from my PfSense machine yet. How can I manually make these changes? From what I read, applying the patch requires internet access. -
@parithosh you can copy-paste it:
From 7a6a322bf1d6208847722e9a91a6397e266b4d87 Mon Sep 17 00:00:00 2001 From: Viktor G <viktor@netgate.com> Date: Wed, 27 May 2020 12:15:18 +0300 Subject: [PATCH] Setting host-uniq for PPPoE. Implements #10597 --- src/etc/inc/interfaces.inc | 10 ++++++++-- src/usr/local/www/interfaces.php | 22 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index a6a9fe60303..7e4a7b4c7ca 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2576,7 +2576,13 @@ EOD; EOD; } - if ($type == "pppoe" && $mtus[$pid] > 1492) { + if (($type == "pppoe") && !empty($ppp['hostuniq'])) { + $mpdconf .= <<<EOD + set host-uniq "0x{$ppp['hostuniq']}" + +EOD; + } + if (($type == "pppoe") && ($mtus[$pid] > 1492)) { $mpdconf .= <<<EOD set pppoe max-payload {$mtus[$pid]} @@ -2597,7 +2603,7 @@ EOD; EOD; } - if ($type == "pptp" || $type == "l2tp") { + if (($type == "pptp") || ($type == "l2tp")) { $mpdconf .= <<<EOD set {$type} self {$localips[$pid]} set {$type} peer {$gateways[$pid]} diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index cefeab14c91..6b6c498a433 100755 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -128,10 +128,11 @@ function remove_bad_chars($string) { $pconfig['phone'] = $a_ppps[$pppid]['phone']; $pconfig['apn'] = $a_ppps[$pppid]['apn']; - } else if ($a_ppps[$pppid]['type'] == "pppoe") { + } elseif ($a_ppps[$pppid]['type'] == "pppoe") { $pconfig['pppoe_username'] = $a_ppps[$pppid]['username']; $pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']); $pconfig['provider'] = $a_ppps[$pppid]['provider']; + $pconfig['hostuniq'] = $a_ppps[$pppid]['hostuniq']; $pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); $pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout']; @@ -843,9 +844,12 @@ interfaces_vlan_configure(); } } - if (($_POST['provider'] && (strpos($_POST['provider'], "\"")))) { + if ($_POST['provider'] && strpos($_POST['provider'], "\"")) { $input_errors[] = gettext("The service name may not contain quote characters."); } + if ($_POST['hostuniq'] && !ctype_xdigit($_POST['hostuniq'])) { + $input_errors[] = gettext("The Host-Uniq field must contain hexadecimal string, for example '6d792d746167'."); + } if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) { $input_errors[] = gettext("The idle timeout value must be an integer."); } @@ -1175,6 +1179,7 @@ interfaces_vlan_configure(); unset($wancfg['pptp_password']); unset($wancfg['l2tp_secret']); unset($wancfg['provider']); + unset($wancfg['hostuniq']); unset($wancfg['ondemand']); unset($wancfg['timeout']); if (empty($wancfg['pppoe']['pppoe-reset-type'])) { @@ -1197,6 +1202,7 @@ interfaces_vlan_configure(); } if ($wancfg['ipaddr'] != 'pppoe') { unset($a_ppps[$pppid]['pppoe-reset-type']); + unset($a_ppps[$pppid]['hostuniq']); } if ($wancfg['type'] != $_POST['type']) { unset($a_ppps[$pppid]['idletimeout']); @@ -1286,6 +1292,11 @@ interfaces_vlan_configure(); } else { $a_ppps[$pppid]['provider'] = true; } + if (!empty($_POST['hostuniq'])) { + $a_ppps[$pppid]['hostuniq'] = strtolower($_POST['hostuniq']); + } else { + $a_ppps[$pppid]['hostuniq'] = true; + } $a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false; if (!empty($_POST['pppoe_idletimeout'])) { $a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout']; @@ -2837,6 +2848,13 @@ function build_port_list() { $pconfig['provider'] ))->setHelp('This field can usually be left empty.'); +$section->addInput(new Form_Input( + 'hostuniq', + 'Host-Uniq', + 'text', + $pconfig['hostuniq'] +))->setHelp('Required by some ISP, usually can be left empty.'); + $section->addInput(new Form_Checkbox( 'pppoe_dialondemand', 'Dial on demand',
-
So i copied over the snippet, applied it with
patch
onto the files/etc/inc/interfaces.inc
and/usr/local/www/interfaces.php
. This created thehost-uniq
field in the WAN page under PPPoE as shown in the image. I entered the same value as your example.However, when I run tcpdump on the VLAN7 interface (needed by the ISP), then I still get random values under
host-uniq
and none of them being the value I set.Is there someway I can check if it has been applied correctly? (I did hit save and Apply changes already).
-
@parithosh PR updated, now it works correctly and I can see Host-Uniq value in packet capture:
From 714657088f4c60cdfcf5b77c17097c0e9e5acd6b Mon Sep 17 00:00:00 2001 From: Viktor G <viktor@netgate.com> Date: Thu, 28 May 2020 09:46:01 +0300 Subject: [PATCH] Setting host-uniq for PPPoE. Implements #10597 --- src/etc/inc/interfaces.inc | 14 +++++++++++--- src/usr/local/www/interfaces.php | 22 ++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index a6a9fe60303..9a43abc9408 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2569,14 +2569,22 @@ EOD; EOD; } if ($type == "pppoe") { + $hostuniq = ''; + if (!empty($ppp['hostuniq'])) { + if (preg_match('/^0x[a-fA-F0-9]+$/', $ppp['hostuniq'])) { + $hostuniq = strtolower($ppp['hostuniq']) .'|'; + } elseif (preg_match('/^[a-zA-Z0-9]+$/i', $ppp['hostuniq'])) { + $hostuniq = '0x' . bin2hex($ppp['hostuniq']) . '|'; + } + } // Send a null service name if none is set. $provider = isset($ppp['provider']) ? $ppp['provider'] : ""; $mpdconf .= <<<EOD - set pppoe service "{$provider}" + set pppoe service "{$hostuniq}{$provider}" EOD; } - if ($type == "pppoe" && $mtus[$pid] > 1492) { + if (($type == "pppoe") && ($mtus[$pid] > 1492)) { $mpdconf .= <<<EOD set pppoe max-payload {$mtus[$pid]} @@ -2597,7 +2605,7 @@ EOD; EOD; } - if ($type == "pptp" || $type == "l2tp") { + if (($type == "pptp") || ($type == "l2tp")) { $mpdconf .= <<<EOD set {$type} self {$localips[$pid]} set {$type} peer {$gateways[$pid]} diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index cefeab14c91..77b4f8c5654 100755 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -128,10 +128,11 @@ function remove_bad_chars($string) { $pconfig['phone'] = $a_ppps[$pppid]['phone']; $pconfig['apn'] = $a_ppps[$pppid]['apn']; - } else if ($a_ppps[$pppid]['type'] == "pppoe") { + } elseif ($a_ppps[$pppid]['type'] == "pppoe") { $pconfig['pppoe_username'] = $a_ppps[$pppid]['username']; $pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']); $pconfig['provider'] = $a_ppps[$pppid]['provider']; + $pconfig['hostuniq'] = $a_ppps[$pppid]['hostuniq']; $pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); $pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout']; @@ -843,9 +844,12 @@ interfaces_vlan_configure(); } } - if (($_POST['provider'] && (strpos($_POST['provider'], "\"")))) { + if ($_POST['provider'] && strpos($_POST['provider'], "\"")) { $input_errors[] = gettext("The service name may not contain quote characters."); } + if ($_POST['hostuniq'] && !preg_match('/^[a-zA-Z0-9]+$/i', $_POST['hostuniq'])) { + $input_errors[] = gettext("The Host-Uniq value can only be hexadecimal or letters and numbers."); + } if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) { $input_errors[] = gettext("The idle timeout value must be an integer."); } @@ -1175,6 +1179,7 @@ interfaces_vlan_configure(); unset($wancfg['pptp_password']); unset($wancfg['l2tp_secret']); unset($wancfg['provider']); + unset($wancfg['hostuniq']); unset($wancfg['ondemand']); unset($wancfg['timeout']); if (empty($wancfg['pppoe']['pppoe-reset-type'])) { @@ -1197,6 +1202,7 @@ interfaces_vlan_configure(); } if ($wancfg['ipaddr'] != 'pppoe') { unset($a_ppps[$pppid]['pppoe-reset-type']); + unset($a_ppps[$pppid]['hostuniq']); } if ($wancfg['type'] != $_POST['type']) { unset($a_ppps[$pppid]['idletimeout']); @@ -1286,6 +1292,11 @@ interfaces_vlan_configure(); } else { $a_ppps[$pppid]['provider'] = true; } + if (!empty($_POST['hostuniq'])) { + $a_ppps[$pppid]['hostuniq'] = strtolower($_POST['hostuniq']); + } else { + $a_ppps[$pppid]['hostuniq'] = true; + } $a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false; if (!empty($_POST['pppoe_idletimeout'])) { $a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout']; @@ -2837,6 +2848,13 @@ function build_port_list() { $pconfig['provider'] ))->setHelp('This field can usually be left empty.'); +$section->addInput(new Form_Input( + 'hostuniq', + 'Host-Uniq', + 'text', + $pconfig['hostuniq'] +))->setHelp('A unique host tag value for this PPPoE client. Leave blank unless a value is required by the service provider.'); + $section->addInput(new Form_Checkbox( 'pppoe_dialondemand', 'Dial on demand',
-
Thank you so much! That works exactly as expected. I seem to still not receive any response to my PADI packet, but i am clarifying with my ISP if something more is required.
-
I need the VLAN7 interface (needed by the ISP), too. How do I convert it into hex?
-
The host-uniq ID has nothing to do with the VLAN. If your ISP needs a VLAN create the that and then use the VLAN interface as the parent for the PPPoE config.
Steve
-
@febu see