Networking Your Way

You may not want to bother with all of the b.s. inherent in setting up static IP addresses via the Network Manager. While this gem may be good idea for someone's laptop (where the network address is acquired automagically by DHCP, and/or networking is done via multiple connections), its probably going to be a real pain in the butt if you want your machine to have a single, static IP address (i.e. so the frontend can talk to the master backend, etc.).

Fire up your favorite text editor and take a look at the "/var/log/messages" file (or, for later versions of Mythbuntu, "/var/log/syslog"). Do a forward search for "eth". You should see the place in the boot sequence where the network driver brings up your network interface. This will list the MAC address of the card and the ethernet device name (e.g. "eth0"). Remember these two pieces of information.

If you can't find the MAC address in "/var/log/messages" or "/var/log/syslog", you can try looking through dmesg to find where the device driver started it. The MAC address should be listed there:

     dmesg | grep eth

If none of those work, there are several other options available to find it. You can try:

     /sbin/ifconfig -a

This more or less assumes that the interface was configured one way or another, perhaps by the Network Manager and DHCP, (although the "-a" option indicates that it need not be up). If that's not the case, you can try:

     /usr/bin/lshw -C network

This should give you the MAC address and maybe the ethernet device name for all of the configured NICs on your system. The MAC address will be listed as "serial".

Alternately, if you know what the NIC's device name is (e.g. eth3), you can use ethtool to dump the first part of the NIC's eeprom to get the MAC address:

     sudo ethtool -e eth3 offset 0 length 6

Note that, if the NIC doesn't get configured because it is not supported by any of the drivers, none of these methods may work. You will need to begin by searching for the NIC on the PCI bus:

     sudo lspci

Once you have the adapter's PCI bus address, you can dump all of the info about the adapter:

     sudo lspci -s nnnn:nn:nn.n -vvv

If worst comes to worst, you will need to look up the PCI ID on the Internet to find out what kind of chipset the NIC uses. For example, looking up 8086:15B8 indicates that the chipset is an Intel I219-V (a late-model Intel gigabit chipset).

Again turning to the Internet, you can figure out which device driver is supposed to work with this chipset. You may have to update or build the driver (see NIC Drivers, above) before your NIC will appear.

Once you have a device driver that talks to your NIC, and it starts the NIC at boot time, you can continue searching forward from that point in dmesg, "/var/log/messages" or "/var/log/syslog" where you found its MAC address, or from the beginning, if you had to resort to other means to get the MAC address.

You may see where udev is remapping your NIC to some other device name (e.g. "udev: renamed network interface eth0 to eth1"). If you don't want this to happen (quite often, the clever little install programs add every NIC they've ever encountered, at some time in the past, to udev's rules so that you end up with "eth0", "eth1", "eth2", etc., even though you only have one NIC now), you should find where udev compares the NIC's MAC address in its rules and maps the NIC to something else. For example:

/etc/udev/rules.d/70-persistent-net.rules:

.

       .

# The line will look something like this SUBSYSTEM=="net", ACTION=="add", DRIVERS="?", \ ATTR{address}=="00:19:66:17:ea:ff", ATTR{type}=="1", KERNEL=="eth", \ NAME="eth1"

       .
       .
       .

Comment out all of the lines that map the former NICs and change the line that maps the current NIC, to map it to "eth0" (or whatever name you really want). In this case, we'd change "eth1" to "eth0". Or, take all of the mapping lines out altogether, if you think the network driver will always assign things in the proper order.

Once you know the name of the NIC, edit the "/etc/network/interfaces" file. If you want a static IP address, your file should look something like this:

/etc/network/interfaces:

     auto lo
     iface lo inet loopback
     auto eth0
     iface eth0 inet static
         address 192.168.1.8
         netmask 255.255.255.0
         gateway 192.168.1.1

You can force the issue by including the actual MAC address in the "/etc/network/interfaces" file, in which case you'll get an error in the log, when you try to bring up networking, if the MAC address ever changes. This may be preferrable to udev just remapping your NIC to eth5 (or whatever), when you install a new one, and having DHCP take over. In that case, networking will appear to be working but when you try to reach the system with its supposed static IP address, you'll get a huge surprise. To force the MAC address to be checked, do this:

     auto eth0
     iface eth0 inet static
         hwaddress ether 00:19:66:17:ea:ff
         address 192.168.1.8
         netmask 255.255.255.0
         gateway 192.168.1.1

For earlier versions of Mythbuntu, you can put your DNS servers directly in "/etc/resolv.conf", optionally along with your domain name search string. This should look something like this:

     search mysite.com
     nameserver 151.203.0.84
     nameserver 151.203.0.85
     nameserver 204.122.16.8
     nameserver 216.231.41.2

However, for later versions of Mythbuntu the resolvconf command is used by the networking scripts to set the DNS servers dynamically, as interfaces are brought up/down. This means that any changes made to "/etc/resolv.conf" will be wiped out in short order. For those systems, the proper way to set the list of DNS servers is with the "dns-nameservers" and "dns-search" commands in the "/etc/network/interfaces" file, like this:

     auto eth0
     iface eth0 inet static
         hwaddress ether 00:19:66:17:ea:ff
         address 192.168.1.8
         netmask 255.255.255.0
         gateway 192.168.1.1
         dns-nameservers 151.203.0.84 151.203.0.85 204.122.16.8 216.231.41.2
         dns-search mysite.com

However, if you want a dynamic IP address that is obtained from DHCP, there is no need to put anything in "/etc/resolv.conf" or "/etc/network/interfaces". Merely change "/etc/network/interfaces" to look like this:

     auto lo
     iface lo inet loopback
     auto eth0
     iface eth0 inet dhcp

Now, we can uninstall the Network Manager using the Package Manager (in later versions of Mythbuntu, the Package Manager has been replaced with a video game called Ubuntu Software Center, whose aim in life appears to be to sell you magazine subscriptions. If you hate this application, like we do, see the "Useful Software" section for notes on how to install the Synaptic Package Manager and the "Useless and Annoying Software" section for notes on how to remove the Ubuntu Software Center). Using one of the GUI package managers (or apt-get, for that matter) is by far and away the easiest way to disable the Network Manager. Search for "network-manager". You should see the network-manager package, and possibly the network-manager-gnome package at the head of the list. Uninstall it (them) and any dependencies too.

Once you're done, you can yo-yo the network down/up. On earlier versions of Mythbuntu, this is accomplished like so, from the console:

     sudo /etc/init.d/networking stop
     sudo /etc/init.d/networking start

On later versions of Mythbuntu, that use upstart, this might be accomplished with, from the console:

     sudo stop networking
     sudo start networking

Although, under Mythbuntu 12.04LTS, this method doesn't work and seems to leave networking sort of in limbo (nice work, guys -- that upstart thingy is a real winner). Of course, the ultimate test is to reboot the system, which works even when upstart doesn't. Either way, a ping to another system should prove that everything is working OK. If you'd like to admire your handiwork, you can try:

     /sbin/ifconfig