Author Topic: Dianemo S with USB NIC  (Read 3347 times)

gtsupport

  • Veteran
  • ***
  • Posts: 147
    • View Profile
Dianemo S with USB NIC
« on: August 06, 2012, 10:00:20 pm »
After a prolonged absence from my system I'm now back at the keyboard. I'm sticking with the Dianemo S system for now but have some new issues  ;D

I noticed that previously when any machine on my network was using a lot of bandwidth, i.e. downloading movies etc. then the core/nerve centre would crash. I've tracked this down to the onboard NIC I believe, so I disabled it and fitted a USB NIC. I did a clean install of 12.04 today and then installed Dianemo from the 1.17 deb. Internet connection worked fine with Ubuntu through the USB NIC, obviously or Dianemo wouldn't have installed. As soon as I rebooted the machine after the installation there was no network connection to the internet from the core; the network settings show no external Mac address, or IP address. If I go to the desktop and try firefox, or any command line command, such as apt-get.....etc there is no network connection.

So how do I tell the system that it should use the USB NIC for the external connection?

Cheers

Matt
LinuxMCE - If it was easy, everybody would be doing it!!

totallymaxed

  • LinuxMCE God
  • ****
  • Posts: 4660
  • Smart Home Consulting
    • View Profile
    • Dianemo - at home with technology
Re: Dianemo S with USB NIC
« Reply #1 on: August 07, 2012, 06:37:26 pm »
After a prolonged absence from my system I'm now back at the keyboard. I'm sticking with the Dianemo S system for now but have some new issues  ;D

I noticed that previously when any machine on my network was using a lot of bandwidth, i.e. downloading movies etc. then the core/nerve centre would crash. I've tracked this down to the onboard NIC I believe, so I disabled it and fitted a USB NIC. I did a clean install of 12.04 today and then installed Dianemo from the 1.17 deb. Internet connection worked fine with Ubuntu through the USB NIC, obviously or Dianemo wouldn't have installed. As soon as I rebooted the machine after the installation there was no network connection to the internet from the core; the network settings show no external Mac address, or IP address. If I go to the desktop and try firefox, or any command line command, such as apt-get.....etc there is no network connection.

So how do I tell the system that it should use the USB NIC for the external connection?

Cheers

Matt

Hi Matt,

You have changed the hardware profile of your NC by changing the WAN side NIC. Please either PM me on the forum or email to me the Mac address of the NIC you are replacing and the Mac address of the new USB NIC. I will then update our DB.

Then you need to make some changes at your NC;

You need to edit /etc/udev/rules.d/70-persistent-net.rules and replace the failed NIC in there with the new one (i.e. new MAC in ATTR{address} on the line where the failed NIC is) and delete the entry that Ubuntu added for the new NIC.

Alternatively you could do it the following way;

Delete the failed NIC, and change NAME= on the line that Ubuntu added in there for the new NIC to the value of the failed one. Then reboot your NC to have the changes take effect.

All the best

Andrew
« Last Edit: August 07, 2012, 08:21:04 pm by totallymaxed »
Andy Herron,
CHT Ltd

For Dianemo/LinuxMCE consulting advice;
@herron on Twitter, totallymaxed+inquiries@gmail.com via email or PM me here.

Get Dianemo-Rpi2 ARM Licenses http://forum.linuxmce.org/index.php?topic=14026.0

Get RaspSqueeze-CEC or Raspbmc-CEC for Dianemo/LinuxMCE: http://wp.me/P4KgIc-5P

Facebook: https://www.facebook.com/pages/Dianemo-Home-Automation/226019387454465

http://www.dianemo.co.uk

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1084
    • View Profile
Re: Dianemo S with USB NIC
« Reply #2 on: August 10, 2012, 09:07:45 am »
Hi Andrew. In order to add/change nics I also run:

Code: [Select]
Nic_Config () {
echo "Starting NIC Discovery and Configuration" > $MESSGFILE
# Find out, what nic configuration we have. This is needed for later on to fill the database
# correctly.
if  [[ `ifconfig -s -a  | awk '$1 != "Iface" && $1 != "lo" && $1 != "pan0" { print $1 }' | wc -l` > 1 ]]; then
Create_Wizard_Data-Double_Nic_Shell > ${mce_wizard_data_shell}
#Use these for the defaults if we cannot automatically determine which to use
#TODO: Error out and instruct the user to setup a working connection? Or ask them to manually choose?
extif="eth0"
intif="eth1"
if route -n | grep -q '^0.0.0.0'; then
#We have a default route, use it for finding external interface.
extif=`route -n | awk '$1 == "0.0.0.0" { print $8 }'`
#Use the first available interface as the internal interface.
for if in `ifconfig -s -a | awk '$1 != "Iface" && $1 != "lo"  && $1 != "pan0" { print $1 }'`; do
if [ "$if" != "$extif" ]
then
intif=$if
break
fi
done
fi
echo "Using $extif for external interface" > $MESSGFILE
sleep 2
echo "Using $intif for internal interface" > $MESSGFILE
sed --in-place -e "s,\({extif}\),$extif,g" ${mce_wizard_data_shell}
sed --in-place -e "s,\({intif}\),$intif,g" ${mce_wizard_data_shell}
else
extif=eth0
if route -n | grep -q '^0.0.0.0'
then
#We have a default route, use it for finding external interface.
extif=`route -n | awk '$1 == "0.0.0.0" { print $8 }'`
fi
Create_Wizard_Data-Single_Nic_Shell > ${mce_wizard_data_shell}
echo "Using $extif for single nic install" > $MESSGFILE
sed --in-place -e "s,\({extif}\),$extif,g" ${mce_wizard_data_shell}
# set c_netExtIP and friends , as this is used in Configure_Network_Options (i.e. before Network_Setup...)
extIP=$(ip addr | grep "$extif" | grep -m 1 'inet ' | awk '{print $2}' | cut -d/ -f1)
sed --in-place -e "s,\({extip}\),$extIP,g" ${mce_wizard_data_shell}
# Set use external DHCP and run own dhcp based on extifs current setting
ExtUsesDhcp=$(grep "iface $extif " /etc/network/interfaces | grep -cF 'dhcp')
if [[ $ExtUsesDhcp == 0 ]]
then
   # Not dhcp defined in config file, test if dhclient got us an IP
   # /var/run/dhcp3 for newer than 810, /var/run in 810
   if [[ (`ls /var/lib/dhcp3/dhclient-*-$extif.lease && [[ $? == 0 ]]` || -e /var/run/dhclient-$extif.pid) && `pgrep -c dhclient` == 1 ]]
   then
   ExtUsesDhcp=1
   fi
fi
RunDHCP=0
if [[ $ExtUsesDhcp == 0 ]]
then
echo "$extif does not use DHCP, setting ExtUseDhcp=0 and RunDHCPServer=1 and detecting current network settings" > $MESSGFILE
RunDHCP=1
ExtGateway=$(grep -A 10 "^iface $extif" /etc/network/interfaces | grep '^\s*gateway' -m 1 | grep -o  '[0-9.]*')
ExtMask=$(grep -A 10 "^iface $extif" /etc/network/interfaces | grep '^\s*netmask' -m 1 | grep -o '[0-9.]*')
ExtDNS=$(grep 'nameserver' /etc/resolv.conf | grep -o '[0-9.]*' -m 1)
fi
sed --in-place -e "s,\({extMask}\),$ExtMask,g" ${mce_wizard_data_shell}
sed --in-place -e "s,\({extGW}\),$ExtGateway,g" ${mce_wizard_data_shell}
sed --in-place -e "s,\({extDNS}\),$ExtDNS,g" ${mce_wizard_data_shell}
sed --in-place -e "s,\({extUseDhcp}\),$ExtUsesDhcp,g" ${mce_wizard_data_shell}
sed --in-place -e "s,\({runDhcp}\),$RunDHCP,g" ${mce_wizard_data_shell}
fi
if [[ ! -r ${mce_wizard_data_shell} ]]; then
echo "`date` - Wizard Information is corrupted or missing." > $MESSGFILE
exit 1
fi
. ${mce_wizard_data_shell}
VerifyExitCode "MCE Wizard Data"
Core_PK_Device="0"
#Setup the network interfaces
echo > /etc/network/interfaces
echo "auto lo" >> /etc/network/interfaces
echo "iface lo inet loopback" >> /etc/network/interfaces
echo >> /etc/network/interfaces
echo "auto $c_netExtName" >> /etc/network/interfaces
if [[ $c_netExtUseDhcp  == "1" ]] ;then
echo "    iface $c_netExtName inet dhcp" >> /etc/network/interfaces
else
if [[ "$c_netExtIP" != "" ]] && [[ "$c_netExtName" != "" ]] &&
   [[ "$c_netExtMask" != "" ]] && [[ "$c_netExtGateway" != "" ]] ;then
echo "" >> /etc/network/interfaces
echo "    iface $c_netExtName inet static" >> /etc/network/interfaces
echo "    address $c_netExtIP" >> /etc/network/interfaces
echo "    netmask $c_netExtMask" >> /etc/network/interfaces
echo "    gateway $c_netExtGateway" >> /etc/network/interfaces
fi
fi
echo "" >> /etc/network/interfaces
echo "auto $c_netIntName" >> /etc/network/interfaces
echo "    iface $c_netIntName inet static" >> /etc/network/interfaces
echo "    address $c_netIntIPN" >> /etc/network/interfaces
echo "    netmask 255.255.255.0" >> /etc/network/interfaces
}

Configure_Network_Options () {
# Updating hosts file and the Device_Data for the core with the internal and external network
# addresses - uses Initial_DHCP_Config.sh from the pluto-install-scripts package.
echo "Configuring your internal network" > $MESSGFILE
#Source the SQL Ops file
## Setup /etc/hosts
cat <<EOL > /etc/hosts
127.0.0.1 localhost.localdomain localhost
$c_netExtIP dcerouter $(/bin/hostname)
EOL
error=false
Network=""
Digits_Count=0
for Digits in $(echo "$c_netIntIPN" | tr '.' ' ') ;do
[[ "$Digits" == *[^0-9]* ]]     && error=true
[[ $Digits -lt 0 || $Digits -gt 255 ]] && error=true
if [[ "$Network" == "" ]] ;then
Network="$Digits"
else
Network="${Network}.${Digits}"
fi
Digits_Count=$(( $Digits_Count + 1 ))
done
[[ $Digits_Count -lt 1 || $Digits_Count -gt 3 ]] && error=true
if [[ "$error" == "true" ]] ;then
Network="192.168.80"
Digits_Count="3"
fi
IntIP="$Network"
IntNetmask=""
for i in `seq 1 $Digits_Count` ;do
if [[ "$IntNetmask" == "" ]] ;then
IntNetmask="255"
else
IntNetmask="${IntNetmask}.255"
fi
done
for i in `seq $Digits_Count 3` ;do
if [[ $i == "3" ]] ;then
IntIP="${IntIP}.1"
else
IntIP="${IntIP}.0"
fi
IntNetmask="${IntNetmask}.0"
done
if [[ "$c_netIntName" == "" ]] ;then
IntIf="$c_netExtName:0"
else
IntIf="$c_netIntName"
fi
if [[ "$c_singleNIC" == "1" ]] ;then
#Disable firewalls on single NIC operation, refs #396
echo "We are in single NIC mode -> internal firewalls disabled"
echo "DisableFirewall=1" >>/etc/pluto.conf
echo "DisableIPv6Firewall=1" >>/etc/pluto.conf
fi
if [[ "$c_netExtUseDhcp" == "0" ]] ;then
NETsetting="$c_netExtName,$c_netExtIP,$c_netExtMask,$c_netExtGateway,$c_netExtDNS1|$IntIf,$IntIP,$IntNetmask"
else
NETsetting="$c_netExtName,dhcp|$IntIf,$IntIP,$IntNetmask"
fi
DHCPsetting=$(/usr/pluto/install/Initial_DHCP_Config.sh "$Network" "$Digits_Count")
Q="REPLACE INTO Device_DeviceData(FK_Device,FK_DeviceData,IK_DeviceData) VALUES('$Core_PK_Device',32,'$NETsetting')"
RunSQL "$Q"
if [[ "$c_runDhcpServer" == "1" ]]; then
Q="REPLACE INTO Device_DeviceData(FK_Device, FK_DeviceData, IK_DeviceData)
VALUES($Core_PK_Device, 28, '$DHCPsetting')"
RunSQL "$Q"
fi
# create empty IPv6 tunnel settings field
Q="REPLACE INTO Device_DeviceData(FK_Device,FK_DeviceData,IK_DeviceData) VALUES('$Core_PK_Device',292,'')"
RunSQL "$Q"
}

SetupNetworking () {
rm -f /etc/X11/xorg.conf
rm -f /etc/network/interfaces
## Reconfigure networking
/usr/pluto/bin/Network_Setup.sh
/usr/pluto/bin/ConfirmInstallation.sh
/usr/pluto/bin/Timezone_Detect.sh
}

Nic_Config
Configure_Network_Options
SetupNetworking

In a script to set values up in the DB appropriately after changing udev net.rules. I am sure that you have a less complicated method of doing this... just thought I would throw it out there.
I never quit... I just ping out.