Change Primary Network Interface (NIC Upgrade)

tfbox
Posts: 16
Joined: Mon Jun 01, 2009 7:33 pm

Change Primary Network Interface (NIC Upgrade)

Postby tfbox » Fri Jun 19, 2009 10:15 pm

There is now a wiki page collecting this info http://wiki.amahi.org/index.php/ETH1

I have installed a gigabit network card in my hda to replace the onboard 100mb NIC. Now I am having trouble getting the dhcp server to serve on the new interface. So far after shutting down and installing the new card I started the server, logged in and went to System > Administration > Network in gnome and disabled the old NIC (eth0) and then enabled the new NIC (eth1). Then I set the IP of the new NIC staticly to what the old one was set to. Unfortunatly DHCP is now not working on my network. Which configuration file controls the interface the dhcpd serves on? Am I going to have trouble with other services as well that are serving on the original NIC (eth0)?

Thanks in advance :)
Last edited by tfbox on Sat Jul 18, 2009 11:42 pm, edited 1 time in total.

tfbox
Posts: 16
Joined: Mon Jun 01, 2009 7:33 pm

Re: Change Primary Network Interface (NIC Upgrade)

Postby tfbox » Fri Jun 19, 2009 10:58 pm

I have found that restarting the computer has allowed the service to restart and the new interface is now serving dhcp.
I suppose that restarting the services in /etc/init.d would have also done the same thing. :roll:

tfbox
Posts: 16
Joined: Mon Jun 01, 2009 7:33 pm

Re: Change Primary Network Interface (NIC Upgrade)

Postby tfbox » Fri Jul 10, 2009 12:54 pm

Looks like using eth1 as the primary interface can cause other problems. (ie VPN)
I am going to try to rename eth0 to eth1 and rename eth1 to eth0.
http://www.science.uva.nl/research/air/ ... rfaceNames

gjc1000
Pro User
Pro User
Posts: 133
Joined: Sat Jan 03, 2009 8:30 am

Re: Change Primary Network Interface (NIC Upgrade)

Postby gjc1000 » Fri Jul 10, 2009 7:43 pm

gjc1000
Chi pecora si fa, il lupo se la mangia.

User avatar
moredruid
Expert
Posts: 791
Joined: Tue Jan 20, 2009 1:33 am
Location: Netherlands
Contact:

Re: Change Primary Network Interface (NIC Upgrade)

Postby moredruid » Sat Jul 11, 2009 11:48 am

if you need to switch the eth1 & eth0 around I've got this for you:

copy the code and paste it in a file (e.g. switchnic) in /root/ and chmod u+x it.
to run: switchnic [-d] iface1 iface2 ( so that would be: ./switchnic -d eth0 eth1 )
if different drivers are used the drivers will be corrected as well.

Code: Select all

#!/bin/bash # # NAME # switchnics - switch network interface hardware settings # # USAGE # switchnics [-d] iface1 iface2 # # DESCRIPTION # Switch network interface hardware settings originally assigned by # the Red Hat installer, anaconda. The interface configuration files # in /etc/sysconfig/network-scripts are modified so the MAC addresses # are exchanged for the HWADDR shell variables. Optional comment # on line 1 of these files are exchanged and, if necessary, the # driver assignments in /etc/modprobe.conf are switched as well. # # MODIFICATION HISTORY # * Wed Feb 13 2008 George Hacker <ghacker@redhat.com> # - Add the -d option to switch device names instead of HW settings # * Fri Dec 14 2007 George Hacker <ghacker@redhat.com> # - Original code. # fatal() - writes to STDERR, then exits function fatal () { echo "$1" 1>&2; exit $2 } # Check the options to see if the user is a knucklehead if [[ $# -eq 2 ]] then unset SW_DEVICE iface[1]=$1; iface[2]=$2 elif [[ $# -eq 3 && $1 = -d ]] then SW_DEVICE=true iface[1]=$2; iface[2]=$3 else fatal "Usage: $(basename $0) [-d] iface1 iface2" 2 fi if [[ ${iface[1]} = ${iface[2]} ]] then fatal "Error: you specified the same interface" 2 fi exit modprobe=/etc/modprobe.conf ifcfg=/etc/sysconfig/network-scripts/ifcfg- # Determine the drivers for each of the interfaces for i in 1 2 do if grep "alias ${iface[i]}" $modprobe &> /dev/null then driver[i]=$( awk "/${iface[i]}/ { print \$3 }" $modprobe ) else fatal "Error: interface ${iface[i]} does not exist" 1 fi done # Retrieve the interface comment lines and the DEVICE and HWADDR values for i in 1 2 do if [[ ! -w $ifcfg${iface[i]} ]] then fatal "Error: cannot write to $(basename $ifcfg${iface[i]})" 1 fi comment[i]=$( awk 'NR == 1 && /^#/' $ifcfg${iface[i]} ) hwaddr[i]=$( awk -F= '$1 == "HWADDR" { print $2 }' $ifcfg${iface[i]} ) device[i]=$( awk -F= '$1 == "DEVICE" { print $2 }' $ifcfg${iface[i]} ) done # When -d option is used, switch the DEVICE lines, not HWADDR and comments if [[ $SW_DEVICE ]] then TEMP="${device[1]}" ; device[1]="${device[2]}" ; device[2]="$TEMP" else TEMP="${comment[1]}"; comment[1]="${comment[2]}"; comment[2]="$TEMP" TEMP="${hwaddr[1]}" ; hwaddr[1]="${hwaddr[2]}" ; hwaddr[2]="$TEMP" fi # If the drivers are different, modify modprobe.conf if [[ ${driver[1]} != ${driver[2]} ]] then if [[ ! -w $modprobe ]] then fatal "Error: cannot write to $(basename $modprobe)" 1 fi # Switch modprobe.conf entries sed -e "/alias ${iface[1]}/s/${driver[1]}/${driver[2]}/" \ -e "/alias ${iface[2]}/s/${driver[2]}/${driver[1]}/" -i $modprobe fi # Create new and improved interface config files for i in 1 2 do ( if [[ -n ${comment[i]} ]] then echo ${comment[i]} fi awk -F= "BEGIN { OFS=\"=\"} NR == 1 && /^#/ { next } \$1 == \"HWADDR\" { \$2 = \"${hwaddr[i]}\" } \$1 == \"DEVICE\" { \$2 = \"${device[i]}\" } { print }" $ifcfg${iface[i]} ) > $ifcfg${iface[i]}.tmp cp $ifcfg${iface[i]}.tmp $ifcfg${iface[i]} rm $ifcfg${iface[i]}.tmp done # When -d option is used, IP config settings get switched, so files # have to be exchanged if [[ $SW_DEVICE ]] then mv $ifcfg${iface[1]} $ifcfg.tmp mv $ifcfg${iface[2]} $ifcfg${iface[1]} mv $ifcfg.tmp $ifcfg${iface[2]} fi exit 0
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D2173656C7572206968616D41snlbxq' | dc
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD

tfbox
Posts: 16
Joined: Mon Jun 01, 2009 7:33 pm

Re: Change Primary Network Interface (NIC Upgrade)

Postby tfbox » Sat Jul 18, 2009 10:51 pm

Thanks for the posts guys. My situation is: I was using the 100mbit onboard ethernet port. than after a while I decided to upgrade to a 1gigabit card. I tried to just disable the onboard ethernet in the bios of the machine but that just makes eth0 disappear and eth1 remains. I also tried that script but I don't think it worked. :S So rather than re-install; what I have done to make everything work is just edit the conf files when I notice something is not working. Here is a list of the conf files needed to be edited to make the various services/apps work.

cpg mentioned that /usr/bin/hdactl needs a change near the top to make some of the dhcp dns scripts be managed correctly.
about line 21.

Code: Select all

my $device = "eth1";
  • Openvpn:
file to edit: /etc/openvpn/openvpn-startup
one of the iptables rules in there has eth0 in it.
carefully change it to your new primary interface
ie:

Code: Select all

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth1 -j MASQUERADE
  • ushare:
file to edit: /var/hda/apps/ushare/ushare.conf
where it says "USHARE_IFACE=" add your new primary interface to that.
ie:

Code: Select all

USHARE_IFACE=eth1

ceayuso
Posts: 14
Joined: Sun Jan 18, 2009 7:35 pm

Re: Change Primary Network Interface (NIC Upgrade)

Postby ceayuso » Tue Jul 21, 2009 11:28 am

I have been running on eth1 for a while now. One thing I remember doing is copying info from ifcfg-eth0 to ifcfg-eth1.

User avatar
moredruid
Expert
Posts: 791
Joined: Tue Jan 20, 2009 1:33 am
Location: Netherlands
Contact:

Re: Change Primary Network Interface (NIC Upgrade)

Postby moredruid » Tue Jul 21, 2009 11:46 am

yeah, just make sure the MAC addresses are kept in the original files, the rest can be swapped.
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D2173656C7572206968616D41snlbxq' | dc
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD

coolstone
Posts: 16
Joined: Sat Mar 13, 2010 11:01 am

Re: Change Primary Network Interface (NIC Upgrade)

Postby coolstone » Fri Jul 13, 2012 12:21 am

Hey tfbox,

I am doing the same thing as you did a few years ago. Did you succeed finally? I guess you did. Could you tell me what you got eventually?

Thanks for sharing with me!

And ceayuso, you seemed know this well, could you share with me?

My situation: upgrade on-board lan (eth0) 100M to Giga bit Trendnet card. RTL8169sc (eth1). Automatically detected and installed. But have conflict with each other. And when I pulled the eth1 out, everything works fine.

Thanks for any help!

User avatar
bigfoot65
Project Manager
Posts: 11924
Joined: Mon May 25, 2009 4:31 pm

Re: Change Primary Network Interface (NIC Upgrade)

Postby bigfoot65 » Fri Jul 13, 2012 4:43 am

Try disabling the onboard LAN and see if the add in card works as eth0. If not and you have Desktop access to your HDA, it can be done there.

You access the network card via Network in one of the menus. There is a place in that tool which allows you to rename the card from eth1 to eth0. It may require a reboot, but messing with the setting there will fix it.

This might help as well.

http://wiki.amahi.org/index.php/ETH1
ßîgƒσστ65
Applications Manager

My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 16GB RAM, 1TBx1+2TBx2+4TBx2

Who is online

Users browsing this forum: No registered users and 4 guests