Computer Scientist, Graduate Student, and Geek

Category: Networking

Fix X11 Forwarding over SSH in Ubuntu 10.04 (Lucid)

October 13, 2011

There is a bug in Ubuntu Lucid’s sshd (SSH server) that causes issues with IPv6-enabled network interfaces preventing X11 forwarding over SSH from working properly. The error in /var/log/auth.log is:

error: Failed to allocate internet-domain X11 display socket.

To fix the issue, you need to tell sshd to only listen to IPv4. Add the following line at the top of /etc/ssh/sshd_config (before the Port configuration):

AddressFamily inet

Solution is from: http://www.se.cuhk.edu.hk/~hmleung/wordpress/?p=876

Categories: Linux, Networking

Tags: ssh, ubuntu


Persistent Iptables in Ubuntu

September 09, 2011

Fedora defaults to persisting iptables (the Linux firewall) between restarts, but this is not the default case in Ubuntu. To have iptables persist between reboots in Ubuntu, you can install the iptables-persistent package:

sudo apt-get install iptables-persistent
The persistent tables will be stored in /etc/iptables/rules by default. You can save the live iptables to the persistent file using:
sudo iptables-save< /etc/iptables/rules

Solution is from https://help.ubuntu.com/community/IptablesHowTo#Configuration_on_startup

Categories: Linux, Networking

Tags: iptables, ubuntu


Install SNMP on Ubuntu

May 06, 2011

To install SNMP on Ubuntu, run the commands below (as root):

apt-get install -y snmpd

CONFIG="/etc/snmp/snmpd.conf"
mv $CONFIG $CONFIG.bak
echo rocommunity  public > $CONFIG
echo syslocation  "put location here" >> $CONFIG
echo syscontact   youremail@yourdomain.com >> $CONFIG

CONFIG="/etc/default/snmpd"
mv $CONFIG $CONFIG.bak
cat $CONFIG.bak | grep -v SNMPDOPTS > $CONFIG
echo "SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid \
        -c /etc/snmp/snmpd.conf'" >> $CONFIG

service snmpd restart

echo "Installed snmpd"

If you have a firewall, you will also need to allow UDP traffic on port 161. If you use iptables this can be accomplished with

iptables -A INPUT -p udp -m state --state NEW -m udp --dport 161 -j ACCEPT

You can test if SNMP is working by running snmpwalk from another machine:

snmpwalk -v 1 -c public -O e hostname

This blog posted is based on documentation at http://www.it-slav.net/blogs/2009/02/05/install-and-configure-snmp-on-ubuntu.

Categories: Linux, Networking

Tags: snmp, ubuntu


Permanently Change Hostname in Ubuntu

February 15, 2011

To permanently to change the hostname of an Ubuntu box, edit the file /etc/hostname. (You need to be root to change this file.) Modify the single line the file contains.

Categories: Linux, Networking

Tags: hostname, ubuntu


Deleting a Route

February 09, 2011

Use the route command on Linux to view and delete entries from the routing table. To remove a route for a specific subnet, use the command:

route del -net DST netmask MASK

replacing DST with the subnet IP and MASK with the subnet mask. For example, to delete a route for the subnet 169.254.0.0/16, run the command:

route del -net 169.254.0.0 netmask 255.255.0.0

Categories: Linux, Networking

Tags: route, subnet


Calculating IP Subnets

December 28, 2010

Being in networking, I frequently need to determine subnet sizes, mask sizes, and address ranges. While I could do this all in my head, I like to use the handy Online IP Subnet Calculator. You can set any number of subnet parameters and get the resulting address range and broadcast address.

Categories: Networking

Tags: subnet


Eeebuntu on ASUS EeePC 1000HA Missing Network Adapters

May 24, 2010

A few weeks ago I helped a friend install Eeebuntu 3 on his ASUS EeePC 1000HA. After installation, no network adapters were being recognized--neither wired or wireless.

The solution was to upgrade to the 2.6.30 Linux kernel, which adds the necessary support for the network hardware in the EeePC 1000HA. The necessary Debian packages can be downloaded from the Ubuntu kernel mirror to a flash drive using a different computer. Then, install the three necessary Debian packages on the EeePC in this order:

  1. linux-headers-2.6.30-020630_2.6.30-020630_all.deb
  2. linux-image-2.6.30-020630-generic_2.6.30-020630_i386.deb
  3. linux-headers-2.6.30-020630-generic_2.6.30-020630_i386.deb
After you install all three packages in Eeebuntu, reboot the EeePC. Linux should recognize both the wired and wireless network adapters. Eeebuntu will try to get you to upgrade to the Linux 2.6.27 kernel via apt, but be sure NOT to install the kernel updates otherwise you'll be right back where you started.

The solution to this issue originally came from an Eeebuntu forum post.

Categories: Linux, Networking

Tags: eeebuntu, eeepc, ubuntu


Monitor Network Usage with MRTG and DD-WRT

January 26, 2010

I currently run DD-WRT on a Linksys WRT54GL. One of the great features of DD-WRT is its Simple Network Management Protocol (SNMP) functionality. You can setup a desktop to gather SNMP data from the router and provide it in nice graphical form.

First, you need to configure the router running DD-WRT:

  1. Login to the DD-WRT web interface by entering the router's IP address in your browser.
  2. Select the Services tab.
  3. Click the Enable radio button under SNMP.
  4. Enter a description for the location (such as "Home"), a name for the contact (such as "Aaron Gember"), and a name for the router (its hostname is a good choice).
  5. Click the Apply Settings button.

After DD-WRT is configured, MRTG needs to be configured. All the commands below are run as root. A few may be Fedora specific, but the commands are easily adaptable for other Linux distributions.

  1. Install MRTG
    yum install mrtg

Categories: Linux, Networking

Tags: dd-wrt, mrtg, wrt54gl


Preventing Auto-Padding in C Structures

January 05, 2010

Most networking applications written in C use structures to easily access the data in a packet header. If all the pieces are appropriately word aligned (i.e. one or more sequential parts of the header total 4-bytes in length), then a regular C structure works just fine. The standard IP, TCP, and UDP headers are all word aligned.

However, the custom packet header I was using for a project was not word aligned. Using a regular structure without any special notation, caused the GNU C compiler (gcc) to automatically add padding to the structure to force one or more sequential variables to be 4-byte aligned. But, the packet should not contain this extra padding. The parts of the header need to be "packed."

To force an entire structure to be packed, add

__attribute__((packed))
at the end of the structure definition. For example:
struct mine { 
short a;
int b;
}__attribute__((packed));

It is important to note that not all architectures will allow "packed" structures. Most RISC architectures require that variables be word-aligned, and generate a fault when memory is read across two words. The x86 and x86_64 architectures allow non-word-aligned variables for backwards compatibility to earlier processor versions. Wikipedia has more details on data structure alignment.

(The original source of this solution is: http://tuxsudh.blogspot.com/2005/05/structure-packing-in-gcc.html)

Categories: Development, Networking

Tags: c


Permanently Change Hostname in Fedora

October 20, 2009

To permanently change the hostname of a Fedora box, edit the file /etc/sysconfig/network. (You need to be root to change this file.) Modify the HOSTNAME line.

Categories: Linux, Networking

Tags: fedora, hostname


Older Entries >>