Archive for the ‘Linux’ Category.

SuSE 9.1 ifconfig weirdness

Have just found out that ifconfig on SuSE 9.2 doesnt seem to show virtual intefaces:

message2:~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:80:3F:2B:7B:60
          inet addr:192.168.0.200  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::280:3fff:fe2b:7b60/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:40203054 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4386872 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2879540080 (2746.1 Mb)  TX bytes:321973799 (307.0 Mb)
          Base address:0x2000 Memory:dd200000-dd220000

eth1      Link encap:Ethernet  HWaddr 00:80:3F:2B:7B:61
          inet addr:XXX.XXX.XXx.XXX  Bcast:XXX.XXX.XXx.XXX  Mask:255.255.255.224
          inet6 addr: fe80::280:3fff:fe2b:7b61/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:66946630 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43575297 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4317777 (4.1 Mb)  TX bytes:4011082191 (3825.2 Mb)
          Base address:0x2040 Memory:dd220000-dd240000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1692 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1692 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:113193 (110.5 Kb)  TX bytes:113193 (110.5 Kb)

message2:~ #

However if you use the ip command from the iproute2 package it shows that in fact eth1 does have some aliases:

message2:~ # ip addr
1: lo:  mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: sit0:  mtu 1480 qdisc noqueue
    link/sit 0.0.0.0 brd 0.0.0.0
3: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:80:3f:2b:7b:60 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.200/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::280:3fff:fe2b:7b60/64 scope link
       valid_lft forever preferred_lft forever
4: eth1:  mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:80:3f:2b:7b:61 brd ff:ff:ff:ff:ff:ff
    inet XXX.XXX.XXx.XXX/YY brd XXX.XXX.XXx.XXX scope global eth1
    inet XXX.XXX.XXx.XXX/YY brd XXX.XXX.XXx.XXX scope global secondary eth1
    inet6 fe80::280:3fff:fe2b:7b61/64 scope link
       valid_lft forever preferred_lft forever
message2:~ #

How weird is that. Versions shown below:

message2:~ # cat /etc/SuSE-release
SuSE Linux 9.1 (i586)
VERSION = 9.1
message2:~ # ifconfig -V
net-tools 1.60
ifconfig 1.42 (2001-04-13)
message2:~ #

NB:IP addresses changed to protect the innocent…

Partitioning >1Tb volumes

If you need to create partitions on a disk (or raid volume) which is larger than 1Tb you will need to use parted and set the disk label to GPT. This is an example session creating 2 1Tb partitions on a 2Tb raid5 volume:

[root@sn-b03 parted]# parted /dev/sdb
GNU Parted 1.6.9
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
Inc.

This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
License for more details.

Using /dev/sdb
Information: The operating system thinks the geometry on /dev/sdb is 291775/255/63.
Therefore, cylinder 1024 ends at 8032.499M.
(parted) mklabel gpt
(parted) mkpart primary 0 1048576
(parted) mkpart primary 1048577 2097152
(parted) p
Disk geometry for /dev/sdb: 0.000-2288754.000 megabytes
Disk label type: gpt
Minor    Start       End     Filesystem  Name                  Flags
1          0.017 -1048576.000  ext3
2     -1048575.000      0.000
(parted) quit
Information: Don't forget to update /etc/fstab, if necessary.

[root@sn-b03 parted]#

PCI device 1283:8212 (Integrated Technology Express, Inc.)

My friend recently got an ATA133 card with this chipset on it. The full proc/pci entry looks like:

    RAID bus controller: PCI device 1283:8212 (Integrated Technology Express, Inc.) (rev 17).
      IRQ 10.
      Master Capable.  No bursts.  Min Gnt=8.Max Lat=8.
      I/O at 0xdcd8 [0xdcdf].
      I/O at 0xdcd0 [0xdcd3].
      I/O at 0xdcc0 [0xdcc7].
      I/O at 0xdcb8 [0xdcbb].
      I/O at 0xdca0 [0xdcaf].

If you want to use this under linux you need to compile in the driver as detailed under the title IT8212F
ATA133 RAID Controller
on this page. To compile up the driver you need to enable scsi in your kernel and link /usr/src/linux-2.4 (or linux-2.6 depending on kernel version) to wherever your linux source tree is. If you are using modules remember to modprobe both scsi and sd_mod.

You then put the created iteraid.o file into

/lib/modules/kernel-version/kernel/drivers/ide/pci/

making directories if you have to.

IPTABLES String match support

I am planning on trying out iptables string match support at some point soon and have found this nice HOWTO on getting it compiled into your kernel

Adding static routes to RedHat 8 and 9

To add a static route to modern RedHat distributions you need to do the following:

Assuming you want to add a route to the 192.168.1.0/24 network via the eth0 network interface to the gateway at 172.16.254 you would create a file called /etc/sysconfig/network-scripts/route-eth0 and in that file put the route:

192.168.1.0/24 via 172.16.1.254

Either ifdown and ifup the interfaces or reboot to see the changes.

Of course you could just add the route manually until the next boot:

route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.16.1.254 dev eth1

RPM Command hangs

I occasionally get rpm commands hanging, they are only killable with a -9. This Redhat bugzilla entry offers a solution:

rm -f /var/lib/rpm/__db*.

Which seems to work…

Forcing a linux NIC to a particular setting

To force a linux nic to 100Meg Full Duplex for example:

[root@ sm-b01 network-scripts]# mii-tool
eth0: no autonegotiation, 100baseTx-HD, link ok
eth1: no autonegotiation, 100baseTx-HD, link ok
[root@sm-b01 root]# mii-tool -F 100baseTx-FD eth0
[root@sm-b01 root]# mii-tool -F 100baseTx-FD eth1
[root@sm-b01 root]# mii-tool
eth0: 100 Mbit, full duplex, link ok
eth1: 100 Mbit, full duplex, link ok

UPDATE: I have since discovered that mii-tool doesnt support gigabit ethernet NICs, to force these to a particular setting, or to see what setting they have auto-negotiated use ethtool, which is included in RedHat 9, but if you dont have it you can get it from Source Forge.

ethtool can be used to set and get the current state:

[root@mon-b01 root]# ethtool eth1
Settings for eth1:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: No
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: puag
        Wake-on: g
        Link detected: yes
[root@mon-b01 root]# ethtool -s eth1 speed 100 duplex full

UPDATE: Have found this post which explains how to set the duplex and speed settings permanently on RedHat 9, although will probably work for most distributions.

The options you can pass to the network drivers (for the e100 module) are well documented here and most of the other network drivers are documented back a page.

Linux PPTP server

This week I will be mainly fooling with VPN’s. First off is a PPTP server so the Windows 2k and XP laptops can connect. I’ve found this little daemon which seems to work perfectly well for XP, 2K machines and my Mac OS X (10.1.3) Powerbook and Imac.

The only fiddly bits with installing poptop is that you need a patched up version of pppd so that you can support all the of Microsoft extensions and force the link to be encrypted.

The first step in creating my pptp server was to install a recent patched up version of pppd, which I found here. Installing this is as easy as installing any other RPM and required no post installation fiddling.

Next up was to install the MPEE (Microsoft Point-to-Point Encryption) support, this comes as a set of kernel modules from the pptpclient project. Their documentation, and download page is here. I used this rpm, because our RedHat 9 machine had been patched up to the 2.4.20-20.9 kernel and is a SMP box.

The final bit of software needed to make all this work was the actually poptop binaries, I could not find a RPM for these so I had to install them from source. Rather than using their current (1.1.4-b4) beta I prefered to use the current stable release (1.1.3) which can be downloaded from here. When I install an application from source I always install the application in accordance to the OFA (Optimal Flexible Architecture) standard, more details of which can be found on Dannys site. Rather than just unpack the source and run ./configure && make && make install as root I use a couple of simple scripts, so that the compile is repeatable and at a later date I can tell exactly what options were used. Below is my Build script

gunzip -c pptpd-1.1.3-20030409.tar.gz | tar xvf -
cd poptop
./configure --prefix=/usr/local/app/poptop-1.1.3
make

and the Install script:

cd poptop
make install

Once poptop was installed I needed to write a couple of simple config files, the options and how all this fits together is documented very well on the poptop home page in their Documentation section, so I will not explain all the options here, but I will include my config files for reference:

/etc/pptpd.conf

speed 115200
option /etc/ppp/pptp-options
debug
localip 10.1.1.100-199
remoteip 10.1.2.100-199
listen 213.52.209.13
pidfile /var/run/pptpd.pid

/etc/ppp/pptp-options

debug
name pptp
domain install.mydomain
auth
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe
ms-dns 172.16.2.11

/etc/ppp/chap-secrets

myusername   pptp    mypassword   10.1.2.100

The final bit of the puzzle was to sort out a nice redhat style start stop script, I couldnt find an existing one so I’ve written one, which you can grab here.

After the daemon has been started its a simple matter of configuring your 2k/XP clients to connect. A nice tutorial of how to configure 2K can be found here.

One last note, if you are connecting to a machine which runs iptables or some similar firewall you will need to allow PPTP into the machine, we run a iptables firewall on our PPTP server, the following rules will allow it through:

iptables -A INPUT -p tcp --destination-port 1723 -j ACCEPT
iptables -A INPUT -p 47 -j ACCEPT

That is all I needed to do to get my clients connecting. It should be noted that the clients were all behind adsl routers (Dlink DSL 504, with forward PPTP turned on), More work needs to be done if your clients are behind a linux NAT box.

DJB Software broken with glibc 2.3.1

I just tried to compile daemontools, ucspi-tcp etc on RedHat 9 and found that they all error in a similar way, complaining about errno.h

Apparently its caused by RedHat using glibc-2.3.1, some nice fellow has created patches for all the djb tools here

Read more here

Memtest

If you need to check the ram on your machine and you happen to be running gentoo:

pddb-a01 linux # emerge -p memtest86

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild  N    ] sys-apps/memtest86-3.0-r1

and then add this to grub.conf:

title=memtest
kernel (hd0,0)/memtest86/memtest.bin

Reboot and the choose the memtest option.