diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-07-14 04:30:31 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-07-14 04:30:31 +0000 |
commit | f36d4bd2977b1de2c30db745ccaa46aff9c6a8a9 (patch) | |
tree | 491e2d4beca0e3291bd08e36d35b1c09de8c28ad /etc | |
parent | 5eab9f144d1fe4e256b66e9b48a892a55fb63815 (diff) | |
download | pfsense-f36d4bd2977b1de2c30db745ccaa46aff9c6a8a9.zip pfsense-f36d4bd2977b1de2c30db745ccaa46aff9c6a8a9.tar.gz |
If the interface has a mac address of ff:ff:ff:ff:ff:ff generate a random mac address and assign.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 0efdac6..d64ab3c 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -93,10 +93,23 @@ function interfaces_lan_configure() { interfaces_wireless_configure($lancfg['if'], $lancfg['wireless']); /* MAC spoofing? */ - if ($lancfg['spoofmac']) + if ($lancfg['spoofmac']) { mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) . " link " . escapeshellarg($lancfg['spoofmac'])); - + } else { + $mac = get_interface_mac_address($lancfg['if']); + if($mac == "ff:ff:ff:ff:ff:ff") { + /* this is not a valid mac address. generate a + * temporary mac address so the machine can get online. + */ + $random_mac = generate_random_mac_address(); + mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) . + " link " . escapeshellarg($random_mac)); + $lancfg['spoofmac'] = $random_mac; + write_config(); + } + } + /* media */ if ($lancfg['media'] || $lancfg['mediaopt']) { $cmd = "/sbin/ifconfig " . escapeshellarg($lancfg['if']); @@ -193,9 +206,21 @@ function interfaces_optional_configure_if($opti) { interfaces_wireless_configure($optcfg['if'], $optcfg['wireless']); /* MAC spoofing? */ - if ($optcfg['spoofmac']) + if ($optcfg['spoofmac']) { mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " link " . escapeshellarg($optcfg['spoofmac'])); + } else { + $mac = get_interface_mac_address($optcfg['if']); + if($mac == "ff:ff:ff:ff:ff:ff") { + /* this is not a valid mac address. generate a + * temporary mac address so the machine can get online. + */ + $random_mac = generate_random_mac_address(); + mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . + " link " . escapeshellarg($random_mac)); + $optcfg['spoofmac'] = $random_mac; + write_config(); + } /* media */ if ($optcfg['media'] || $optcfg['mediaopt']) { @@ -428,9 +453,22 @@ function interfaces_wan_configure() { if (is_array($wancfg['wireless'])) interfaces_wireless_configure($wancfg['if'], $wancfg['wireless']); - if ($wancfg['spoofmac']) + if ($wancfg['spoofmac']) { mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " link " . escapeshellarg($wancfg['spoofmac'])); + } else { + $mac = get_interface_mac_address($wancfg['if']); + if($mac == "ff:ff:ff:ff:ff:ff") { + /* this is not a valid mac address. generate a + * temporary mac address so the machine can get online. + */ + $random_mac = generate_random_mac_address(); + mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . + " link " . escapeshellarg($random_mac)); + $wancfg['spoofmac'] = $random_mac; + write_config(); + } + } /* media */ if ($wancfg['media'] || $wancfg['mediaopt']) { |