Allegro - najwiksze aukcje internetowe, najnisze ceny! Kup i sprzedaj!

Dokument ten opisuje sposób instalacji jądra 2.4.27-rc2 i iptables z IMQ, IPP2P i Patch-O-Matic-NG gdy mamy NAT (maskarada). W chwili gdy piszę te słowa (1 lipca 2004) istnieją następujące wersje programów:
* Jądro 2.4.26 - nowsze do ściągnięcia z www.kernel.org/
* Patch do jądra 2.4.27-rc2
* iptables 1.2.11 - nowsze do ściągnięcia z www.iptables.org/
* patch-o-matic-ng-20040621 - nowsze do ściągnięcia z www.iptables.org/

Konwencje użyte w tym dokumencie

Opis poszczególnych czynności oznaczam drukiem wytłuszczonym i są one numerowane
+ Polecenia wydawane przez użytkownika oznaczam podkreśleniem. Tego plusa na początku każdej linii oczywiście nie wpisujesz.
Moje komentarze wewnątrz poszczególnych punktów są pisane kursywą
Wyniki działania poszczególnych poleceń jest pisana właśnie tak.
(...) oznacza, że tych wyników jest bardzo dużo i wtedy zamieszczam zazwyczaj 3 pierwsze i 3 ostatnie linijki a resztę zastępuje przez (...)

  1. Przechodzisz do katalogo /usr/src
    + cd /usr/src


  2. Ściągasz i instalujesz wersję źródłową najnowszego jądra
    + wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.26.tar.bz2
    Powinieneś otrzymać:
    --11:54:10-- http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.26.tar.bz2
    => `linux-2.4.26.tar.bz2'
    Resolving www.kernel.org... done.
    Connecting to www.kernel.org[204.152.189.116]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 30,772,389 [application/x-bzip2]

    0K .......... .......... .......... .......... .......... 0% 4.44 MB/s
    50K .......... .......... .......... .......... .......... 0% 12.21 MB/s
    100K .......... .......... .......... .......... .......... 0% 6.10 MB/s
    (...)
    29950K .......... .......... .......... .......... .......... 99% 9.77 MB/s
    30000K .......... .......... .......... .......... .......... 99% 12.21 MB/s
    30050K . 100% 1.13 MB/s

    11:54:22 (2.52 MB/s) - `linux-2.4.26.tar.bz2' saved [30772389/30772389]


  3. Rozpakowujesz wersję źródłową jądra:
    + bzip2 -dc linux-2.4.26.tar.bz2 | tar xf -
    Powinieneś otrzymać katalog /usr/src/linux-2.4.26 a w nim rozpakowane jądro


  4. Robimy link symboliczny katalogu /usr/src/linux do /usr/src/linux-2.4.26
    + ln -s linux-2.4.26 linux
    Powinieneś otrzymać katalog /usr/src/linux wskazujący na /usr/src/linux-2.4.26

  5. Przechodzimy do katalogu /usr/src/linux
    + cd /usr/src/linux


  6. Ściągamy patch do jądra 2.4.27-rc2
    + wget http://www.kernel.org/pub/linux/kernel/v2.4/testing/patch-2.4.27-rc2.bz2
    Powinieneś otrzymać:
    --11:56:57-- http://www.kernel.org/pub/linux/kernel/v2.4/testing/patch-2.4.27-rc2.bz2
    => `patch-2.4.27-rc2.bz2'
    Resolving www.kernel.org... done.
    Connecting to www.kernel.org[204.152.189.116]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 797,475 [application/x-bzip2]

    0K .......... .......... .......... .......... .......... 6% 3.26 MB/s
    50K .......... .......... .......... .......... .......... 12% 12.21 MB/s
    100K .......... .......... .......... .......... .......... 19% 5.43 MB/s
    150K .......... .......... .......... .......... .......... 25% 9.77 MB/s
    200K .......... .......... .......... .......... .......... 32% 5.43 MB/s
    250K .......... .......... .......... .......... .......... 38% 12.21 MB/s
    300K .......... .......... .......... .......... .......... 44% 9.77 MB/s
    350K .......... .......... .......... .......... .......... 51% 5.43 MB/s
    400K .......... .......... .......... .......... .......... 57% 12.21 MB/s
    450K .......... .......... .......... .......... .......... 64% 2.33 MB/s
    500K .......... .......... .......... .......... .......... 70% 9.77 MB/s
    550K .......... .......... .......... .......... .......... 77% 12.21 MB/s
    600K .......... .......... .......... .......... .......... 83% 5.43 MB/s
    650K .......... .......... .......... .......... .......... 89% 9.77 MB/s
    700K .......... .......... .......... .......... .......... 96% 12.21 MB/s
    750K .......... .......... ........ 100% 14.05 MB/s

    11:56:58 (6.67 MB/s) - `patch-2.4.27-rc2.bz2' saved [797475/797475]


  7. Rozpakowujesz patch i instalujesz
    + bzip2 -dc patch-2.4.27-rc2.bz2 | patch -p1
    Powinieneś otrzymać:
    patching file Documentation/CodingStyle
    patching file Documentation/Configure.help
    patching file Documentation/DocBook/Makefile
    (...)
    patching file net/sctp/tsnmap.c
    patching file net/sctp/ulpevent.c
    patching file net/sctp/ulpqueue.c


  8. Ściągasz patch jądra z IMQ
    + wget http://www.linuximq.net/patchs/linux-2.4.26-imq.diff
    Powinieneś otrzymać:
    --11:57:19-- http://www.linuximq.net/patchs/linux-2.4.26-imq.diff
    => `linux-2.4.26-imq.diff'
    Resolving www.linuximq.net... done.
    Connecting to www.linuximq.net[63.247.81.158]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 22,186 [text/plain]

    0K .......... .......... . 100% 1.41 MB/s

    11:57:20 (1.41 MB/s) - `linux-2.4.26-imq.diff' saved [22186/22186]


  9. Patchujesz jądro dla IMQ
    + patch -p1  <linux-2.4.26-imq.diff
    Powinieneś otrzymać:
    patching file Documentation/Configure.help
    Hunk #1 succeeded at 3122 (offset 82 lines).
    Hunk #2 succeeded at 9669 (offset 147 lines).
    patching file drivers/net/Config.in
    patching file drivers/net/imq.c
    patching file drivers/net/Makefile
    Hunk #1 succeeded at 170 (offset 2 lines).
    patching file include/linux/imq.h
    patching file include/linux/netfilter_ipv4/ipt_IMQ.h
    patching file include/linux/netfilter_ipv6/ip6t_IMQ.h
    patching file include/linux/skbuff.h
    Hunk #3 succeeded at 222 with fuzz 1.
    patching file net/core/skbuff.c
    patching file net/ipv4/netfilter/Config.in
    patching file net/ipv4/netfilter/ipt_IMQ.c
    patching file net/ipv4/netfilter/Makefile
    patching file net/ipv6/netfilter/Config.in
    patching file net/ipv6/netfilter/ip6t_IMQ.c
    patching file net/ipv6/netfilter/Makefile
    patching file net/sched/sch_generic.c


  10. Przechodzisz do katalogo /usr/src
    + cd /usr/src


  11. Ściągasz iptables
    + wget http://www.iptables.org/files/iptables-1.2.11.tar.bz2
    Powinieneś otrzymać:
    --11:57:21-- http://www.iptables.org/files/iptables-1.2.11.tar.bz2
    => `iptables-1.2.11.tar.bz2'
    Resolving www.iptables.org... done.
    Connecting to www.iptables.org[213.95.27.115]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 156,988 [application/x-tar]

    0K .......... .......... .......... .......... .......... 32% 6.98 MB/s
    50K .......... .......... .......... .......... .......... 65% 12.21 MB/s
    100K .......... .......... .......... .......... .......... 97% 9.77 MB/s
    150K ... 100% 3.23 MB/s

    11:57:22 (9.36 MB/s) - `iptables-1.2.11.tar.bz2' saved [156988/156988]


  12. Rozpakowujesz iptables
    + bzip2 -dc iptables-1.2.11.tar.bz2 | tar xf -


  13. Zmieniasz nazwę /usr/src/iptables-1.2.11 na /usr/src/iptables
    + mv iptables-1.2.11 iptables

  14. Ściągasz Patch-O-Matic-NG
    + wget http://www.iptables.org/files/patch-o-matic-ng-20040621.tar.bz2
    Powinieneś otrzymać:
    --11:57:22-- http://www.iptables.org/files/patch-o-matic-ng-20040621.tar.bz2
    => `patch-o-matic-ng-20040621.tar.bz2'
    Resolving www.iptables.org... done.
    Connecting to www.iptables.org[213.95.27.115]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 370,078 [application/x-tar]

    0K .......... .......... .......... .......... .......... 13% 3.76 MB/s
    50K .......... .......... .......... .......... .......... 27% 12.21 MB/s
    100K .......... .......... .......... .......... .......... 41% 5.43 MB/s
    150K .......... .......... .......... .......... .......... 55% 9.77 MB/s
    200K .......... .......... .......... .......... .......... 69% 6.10 MB/s
    250K .......... .......... .......... .......... .......... 83% 9.77 MB/s
    300K .......... .......... .......... .......... .......... 96% 12.21 MB/s
    350K .......... . 100% 11.14 MB/s

    11:57:23 (7.20 MB/s) - `patch-o-matic-ng-20040621.tar.bz2' saved [370078/370078]


  15. Rozpakowujesz POM-NG
    + bzip2 -dc patch-o-matic-ng-20040621.tar.bz2 | tar xf -

  16. Przechodzisz do katalogu POM-NG
    + cd /usr/src/patch-o-matic-ng-20040621


  17. Instalujesz potrzebne łaty z POM-NG.
    Załóżmy, że potrzebujesz łat "string CONNMARK TTL connlimit iprange mport" to wtedy piszesz:
    + IPTABLES_DIR=/usr/src/iptables KERNEL_DIR=/usr/src/linux ./runme string CONNMARK TTL connlimit iprange mport
    Dla każdej łaty otrzymujesz taki komunikat (przykład dla łaty CONNMARK):
    Welcome to Patch-o-matic (1.17)!

    Kernel: 2.4.27, /usr/src/linux
    Iptables: 1.2.11, /usr/src/iptables
    Each patch is a new feature: many have minimal impact, some do not.
    Almost every one has bugs, so don't apply what you don't need!
    -------------------------------------------------------
    Already applied:

    Testing CONNMARK... not applied
    The CONNMARK patch:
    Author: Henrik Nordstrom
    Status: working


    This patch adds per connection marks, and a target (CONNMARK)
    respective a match (connmark) for using these.

    Usage:

    connmark
    This module matches the netfilter mark field associated
    with a connection (which can be set using the CONNMARK
    target below).

    --mark value[/mask]
    Matches packets in connections with the given
    unsigned mark value (if a mask is specified, this
    is logically ANDed with the mark before the comparison).


    CONNMARK
    This is used to set the netfilter mark value associated
    with the connection

    --set-mark mark
    Set connection mark

    --save-mark
    Set connection mark to the same as the one on the
    packet

    --restore-mark
    Set the netfilter packet mark value to the one
    associated with the connection. This is only valid
    in the mangle table.
    -----------------------------------------------------------------
    Do you want to apply this patch [N/y/t/f/a/r/b/w/q/?]
    Wciskasz 'y' a potem 'Enter' i łata zostaje zainstalowana. Jeśli chciałbyś sobie doinstalować inne łaty na przykład z zakresu 'extra' to piszesz:
    + IPTABLES_DIR=/usr/src/iptables KERNEL_DIR=/usr/src/linux ./runme extra


  18. Przechodzisz do katalogu /usr/src/iptables
    + cd /usr/src/iptables


  19. Pobierasz patch IMQ dla iptables
    + wget http://www.linuximq.net/patchs/iptables-1.2.9-imq1.diff
    Powinieneś otrzymać:
    --12:00:56-- http://www.linuximq.net/patchs/iptables-1.2.9-imq1.diff
    => `iptables-1.2.9-imq1.diff'
    Resolving www.linuximq.net... done.
    Connecting to www.linuximq.net[63.247.81.158]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 5,173 [text/plain]

    0K ..... 100% 4.93 MB/s

    12:00:56 (4.93 MB/s) - `iptables-1.2.9-imq1.diff' saved [5173/5173]


  20. Patchujesz iptables dla IMQ
    + patch -p1 <iptables-1.2.9-imq1.diff
    Powinieneś otrzymać:
    patching file extensions/.IMQ-test6
    patching file extensions/libip6t_IMQ.c
    patching file extensions/.IMQ-test
    patching file extensions/libipt_IMQ.c


  21. Robisz te łaty wykonywalne:
    + chmod +x extensions/.IMQ-test*


  22. Kompilujesz iptables
    + make
    Powinieneś otrzymać:
    Making dependencies: please wait...
    Extensions found: IPv4:IMQ IPv4:mport IPv4:recent IPv4:string IPv6:IMQ IPv6:ah IPv6:esp IPv6:frag IPv6:ipv6header IPv6:hbh IPv6:dst IPv6:rt
    cc -O2 -Wall -Wunused -I/usr/src/linux/include -Iinclude/ -DIPTABLES_VERSION=\"1.2.11\" -D_UNKNOWN_KERNEL_POINTER_SIZE -fPIC -o extensions/libipt_ah_sh.o -c extensions/libipt_ah.c
    (...)
    ar rv libipq/libipq.a libipq/libipq.o
    a - libipq/libipq.o
    rm libiptc/libip4tc.o libipq/libipq.o libiptc/libip6tc.o


  23. Instalujesz iptables
    + make install
    Powinieneś otrzymać:
    cp iptables /usr/local/sbin/iptables
    cp iptables.8 /usr/local/man/man8/iptables.8
    cp iptables-save /usr/local/sbin/iptables-save
    (...)
    cp extensions/libip6t_hbh.so /usr/local/lib/iptables/libip6t_hbh.so
    cp extensions/libip6t_dst.so /usr/local/lib/iptables/libip6t_dst.so
    cp extensions/libip6t_rt.so /usr/local/lib/iptables/libip6t_rt.so


  24. Przechodzisz do katalogu jądra z driverami do sieci:
    + cd /usr/src/linux/drivers/net


  25. Ściagasz patch do współpracy imq z NAT
    + wget http://www.linuximq.net/patchs/imq-nat.diff
    Powinieneś otrzymać:
    --12:01:49-- http://www.linuximq.net/patchs/imq-nat.diff
    => `imq-nat.diff'
    Resolving www.linuximq.net... done.
    Connecting to www.linuximq.net[63.247.81.158]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 409 [text/plain]

    0K 100% 399.41 KB/s

    12:01:49 (399.41 KB/s) - `imq-nat.diff' saved [409/409]


  26. Patchujesz IMQ do współpracy z NAT
    + patch <imq-nat.diff
    Powinieneś otrzymać:
    patching file imq.c
    Hunk #1 succeeded at 38 (offset 1 line).


  27. Przechodzisz do katalogu /usr/src
    + cd /usr/src


  28. Ściagasz moduł ipp2p
    + wget http://rnvs.informatik.uni-leipzig.de/ipp2p/downloads/ipp2p.tar.gz
    Powinieneś otrzymać:
    --12:01:49-- http://rnvs.informatik.uni-leipzig.de/ipp2p/downloads/ipp2p.tar.gz
    => `ipp2p.tar.gz'
    Resolving rnvs.informatik.uni-leipzig.de... done.
    Connecting to rnvs.informatik.uni-leipzig.de[139.18.38.20]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 6,752 [application/x-gzip]

    0K ...... 100% 549.48 KB/s

    12:01:49 (549.48 KB/s) - `ipp2p.tar.gz' saved [6752/6752]


  29. Rozpakowujesz ipp2p
    + tar zxvf ipp2p.tar.gz
    Powinieneś otrzymać:
    ipp2p/
    ipp2p/Makefile
    ipp2p/README
    ipp2p/ipt_ipp2p.c
    ipp2p/ipt_ipp2p.h
    ipp2p/libipt_ipp2p.c


  30. Przechodzisz do katalogu /usr/src/ipp2p
    + cd /usr/src/ipp2p


  31. W pliku Makefile ustawiasz aktualne położenie iptables
    + sed -e s/iptables-1.2.9/iptables/ Makefile >Makefile.tmp
    + mv Makefile.tmp Makefile


  32. Kompilujesz ipp2p
    + make
    Powinienes otrzymać:
    gcc -O2 -Wall -I/lib/modules/2.4.27-rc2/build/include -c ipt_ipp2p.c -D__KERNEL__ -DMODULE -DMODVERSIONS
    gcc -O2 -Wall -DNETFILTER_VERSION=\"1.2.11\" -I/usr/src/iptables/include -fPIC -c libipt_ipp2p.c
    ld -shared -o libipt_ipp2p.so libipt_ipp2p.o


  33. Kopiujesz pliki ipp2p do odpowiednich katalogów:
    + mv libipt_ipp2p.so /usr/local/lib/iptables
    + mv ipt_ipp2p.o /lib/modules/2.4.27-rc2/kernel/net/ipv4/netfilter


  34. Przechodzisz do katalogu /usr/src/linux
    + cd /usr/src/linux


  35. Konfigurujesz wybrane opcje jądra:
    + make menuconfig
    Pamiętaj, żeby IMQ działało to musisz włączyć następujące opcje:
    # Code maturity level options --->Prompt for development and/or incomplete code/drivers
    # Networking options ---> Network packet filtering (replaces ipchains)
    # Networking options ---> IP: Netfilter Configuration ---> IP tables support (required for filtering/masq/NAT)
    # Networking options ---> IP: Netfilter Configuration ---> Packet mangling
    # Networking options ---> IP: Netfilter Configuration ---> IMQ target support
    # Network device support ---> IMQ (intermediate queueing device) support


  36. Kompilujesz jądro
    + make dep
    gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/mkdep scripts/mkdep.c
    make[1]: Entering directory `/usr/src/linux-2.4.26/arch/i386/boot'
    make[1]: Nothing to be done for `dep'.
    (...)
    scripts/mkdep -- `find /usr/src/linux-2.4.26/include/asm /usr/src/linux-2.4.26/include/linux /usr/src/linux-2.4.26/include/scsi /usr/src/linux-2.4.26/include/net /usr/src/linux-2.4.26/include/math-emu \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend
    scripts/mkdep -- init/*.c > .depend


    + make bzImage
    gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/split-include scripts/split-include.c
    scripts/split-include include/linux/autoconf.h include/config
    gcc -D__KERNEL__ -I/usr/src/linux-2.4.26/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 -DKBUILD_BASENAME=main -c -o init/main.o init/main.c
    (...)
    Boot sector 512 bytes.
    Setup is 4650 bytes.
    System is 833 kB
    make[1]: Leaving directory `/usr/src/linux-2.4.26/arch/i386/boot'


    + make modules
    make -C kernel CFLAGS="-D__KERNEL__ -I/usr/src/linux-2.4.26/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include /usr/src/linux-2.4.26/include/linux/modversions.h" MAKING_MODULES=1 modules
    (...)
    make[1]: Entering directory `/usr/src/linux-2.4.26/arch/i386/lib'
    make[1]: Nothing to be done for `modules'.
    make[1]: Leaving directory `/usr/src/linux-2.4.26/arch/i386/lib'


    + make modules_install
    make -C kernel modules_install
    make[1]: Entering directory `/usr/src/linux-2.4.26/kernel'
    make[1]: Nothing to be done for `modules_install'.
    (...)
    mkdir -p pcmcia; \
    find kernel -path '*/pcmcia/*' -name '*.o' | xargs -i -r ln -sf ../{} pcmcia
    if [ -r System.map ]; then /sbin/depmod -ae -F System.map 2.4.27-rc2; fi


  37. Kopiujesz swoje nowe jądro i System.map do katalogu z jądrami np. do /boot
    + mv /usr/src/linux/arch/i386/boot/bzImage /boot/imq-2.4.27-rc2
    + mv System.map /boot/System.map-2.4.27-rc2


  38. W /etc/lilo.conf dopisujesz swoje nowe jądro na przykład tak:
    image = /boot/imq-2.4.27-rc2
    root = /dev/hda1
    label = imq-2.4.27-rc2
    read-only


  39. Uruchamiasz lilo i restartujesz system.

Nieco informacji na tematy poruszany w tym dokumencie znajdziesz na:

Po polsku:

Po angielsku:

Jeśli masz jakieś uwagi, pytania bądź propozycje to pisz na lzur małpa teczowe kropka eu kropka org. Jeśli znalazłeś tu jakiś błąd to napisz koniecznie. Inne wersje tego dokumentu znajdziesz na alfa.tailor.com.pl/imqhtb/imq_htb.html. Pliki użyte w tym dokumencie (poza jądrem) znajdziesz na alfa.tailor.com.pl/imqhtb/2.4.26. Jeśli nie chce Ci się wpisywać tych wszystkich poleceń to możesz użyć skryptów imq1 i imq2. Jeśli masz jakieś problemy to wynik działania tych skryptów znajdziesz na wynik.txt a plik z przykładową konfiguracja jądra na .config

Treść tego dokumentu jest udostępniana na licencji GNU Free Documentation License. Polskie tłumaczenie znajdziesz na http://gnu.org.pl/text/licencja-gnu.html

Kopie tego dokumentu znajdziesz na:

Leszek Żur

MozillaPL.org :: Polska Mozilla!