E4CI0


Сетевой интерфейс
-----------------

    Оставь одежду, всяк сюда входящий..

    оригинал http://madebyevan.com/webgl-water/
    мой мод. http://nelus.tpt.edu.ee/html/webgl-water-ru.html


Некоторые команды
-----------------

  $ ping
  # ifconfig
  # traceroute
  # nslookup
  # nmap


Fixed IP vs DHCP client (default)
---------------------------------

По материалам

  http://www.howtogeek.com/howto/ubuntu
       /change-ubuntu-server-from-dhcp-to-a-static-ip-address/

  # vi /etc/network/interfaces

строки:

  auto eth0
  iface eth0 inet dhcp

изменить на:

  auto eth0
  iface eth0 inet static
          address 192.168.1.100
          netmask 255.255.255.0
          network 192.168.1.0
          broadcast 192.168.1.255
          gateway 192.168.1.1

  # vi /etc/resolv.conf

В строке ‘name server xxx.xxx.xxx.xxx’ прописать gateway IP. (для выяснения IP gateway подать команду ifconfig /all )

  # apt-get remove dhcp-client
  # /etc/init.d/networking restart


Настройка сетевого интерфейса VirtualBox
----------------------------------------

Возможно подключение до 4-х NIC (network interface card)

  +--------------------------------------------------------------+
  | Network                                                      |
  |                                                              |
  | Adapter 1 | Adapter 2 | Adapter 3 | Adapter 4                |
  |                                                              |
  | [v] Enable Network Adapter                                   |
  |                                                              |
  | Attached to: Not Attached                                    |
  |              NAT                                             |
  |              NAT Network                                     |
  |              Bridged Adapter                                 |
  |              Internal Network                                |
  |              Host-only Adapter                               |
  |              Generic Driver                                  |
  |                                                              |
  | V Advanced                                                   |
  |                                                              |
  | Adapter Type: PCnet-PCI II (Am79C970A)                       |
  |               PCnet-FAST III (Am79C973)                      |
  |             > Intel PRO/1000 MT Desktop (82540EM) <          |
  |               Intel PRO/1000 T Server (82543GC)              |
  |               Intel PRO/1000 T Server (82545EM)              |
  |               Paravirtualized Network (virtio-net)           |
  |                                                              |
  | MAC Address:  080027F3132E                                   |
  |               [v] Cable Connected                            |
  |                                                              |
  |               [ Port Forwarding ]                            |
  |                                                              |
  | Adapter Type                                                 |
  |                                                              |
  | Rule name   Protocol    Host IP     Port   Guest IP    Port  |
  |                                                              |
  | Rule 1      TCP         127.0.0.1   22     10.0.2.15   22    |
  +--------------------------------------------------------------+


Наиболее интересны в контексте данной темы:

1. NAT Network (виртуальные машины за NATом видят друг друга, имея разные IP адреса 10.0.2.15, 10.0.2.4,..):

    Oracle VM VirtualBox Manager (4.3.10) ->
      File -> Preferences -> Network -> NAT Network
      Active  Name
      [v]     NatNetwork

    Виртуальные машины подключать к NAT Network.

2. NAT + Internal Network:

  Сделать виртуальный gateway:

    1 NIC on NAT, 3 NIC internal network
    IP Masquerade 1-2, 1-3, 1-4
    DHCP

  Виртуальные машины подключать к Internal Network

Изучение всех ветвей дерева возможностей настройки сети нецелесообразно из-за большого объема. Предлагается такой способ:

  -- Выбор ветви с запоминанием в стеке возврата (например записная книжка).

  -- Ознакомление с конфигурационным файлом/документацией (следует ознакомиться с языком читаемого настроечного файла, скрипта, описания, поиск в интернете)

  -- Поиск зависимостей (dependencies) модуля и их запоминание.

  -- Внесение требуемых изменений и переход к следующему объекту.


Изучение на примерах
--------------------

  -- Постановка задачи (чего нужно добиться).

  -- Решение задачи. Запись "Walkthrough" (как достигнута цель) и использованных источников.

  -- Опробовать "Walthrough" (желательно лицом, еще не решавшим данную задачу).

Удобно также фиксировать затраченное на задачу время (start: 00:00 finish 00:01)


Кто виноват и что делать?
-------------------------

Для слова Сеть есть множество переводов. В английском слова network, mesh, grid это не совсем одно и то же (паутина -- web сюда не входит из-за радиальной структуры с явно выраженным центром). Поэтому подробности настройки Unix компьютера (первоочередные задачи перечисляются ниже) в виде HOWTO или скриптов будем добавлять по мере поступления*

  Wired USB ethernet card
  Wireless USB NIC
  3G/4G USB modem

  dhcp
  dns (dnsmasq, bind,..)
  nat (iptables masquerade,..)
  telnet
  SSH
  ftp (vsftp, proftp, pureftp,..)
  http (virtual hosting with apache, apache2, ngnix,..)
  nfs
  samba
  dns
  mail (sendmal, exim,..)
  pxe (http://www.howtoforge.com/ubuntu_pxe_install_server 2006 ubuntu,
       http://clonezilla.org/livepxe.php
       http://wiki.hackzine.org/sysadmin/debian-pxe-server.html)
  mysql

  computer virtualization: xen, user mode linux, vmware, virtualbox,..
  repo mirror
  squid
  snord

*) A recreation of Microsoft's Visual Basic that runs and compiles for/in Linux. We've decided that VB4Linux will be programmed in C. We will probably be beginning sometime within the next week or so... Still looking for developers!. Registered 2000-10-31,  Last Update: 2013-04-11, http://sourceforge.net/projects/vb4linux/)


Задача 1. Ограничить доступ в виртуальную машину
          "Trusty Tahr" локальным хостом.
------------------------------------------------

Решение. Установить TT c "mini.iso" CD на SATA HDD 8GB (default partition scheme).

  wget -c http://archive.ubuntu.com/ubuntu/dists/trusty                \
               /main/installer-i386/current/images/netboot/mini.iso

  hostname: trusty
  mirror:   Estonia
  user:     virtu
  password: virtu

  choose software to install: [v] OpenSSH Server

Windows 81u1-en host:

C:\Users\kiril_000>ipconfig

  Ethernet adapter Ethernet:

     Connection-specific DNS Suffix  . : lan
     Link-local IPv6 Address . . . . . : fe80::b901:273f:e870:9bf7%3
     IPv4 Address. . . . . . . . . . . : 192.168.1.65
     Subnet Mask . . . . . . . . . . . : 255.255.255.0
     Default Gateway . . . . . . . . . : 192.168.1.254

Правило проброса порта

  | Rule name   Protocol    Host IP     Port   Guest IP    Port  |
  |                                                              |
  | Rule 1      TCP                     22                 22    |

Проверить доступ к SSH с другой машины в данном сегменте (192.168.1.66, Windows XP SP3 Rus)

  Есть

Изменить правило проброса порта

  | Rule name   Protocol    Host IP     Port   Guest IP    Port  |
  |                                                              |
  | Rule 1      TCP         127.0.0.1   22     10.0.2.15   22    |

Проверить доступ к SSH с другой машины в данном сегменте

  Нет

Start:  19:30
Finish: 20:50

------------------------------------------------------------------------

Задача 2. Воздействие изменения MAC адреса на конфигурационные файлы udev
-------------------------------------------------------------------------

  root@trusty:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 08:00:27:c2:ff:9e
            inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
            inet6 addr: fe80::a00:27ff:fec2:ff9e/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:336 errors:0 dropped:0 overruns:0 frame:0
            TX packets:242 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:33212 (33.2 KB)  TX bytes:36692 (36.6 KB)

  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:65536  Metric:1
            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@trusty:~# init 0

На хосте: MAC address refresh 080027C2FF9E -> 0800273F0EF1
          Загрузить Trusty Tahr virtual machine (NAT)

  virtu@trusty:~$ ifconfig
  eth0      Link encap:Ethernet  HWaddr 08:00:27:3f:0e:f1
            inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
            inet6 addr: fe80::a00:27ff:fe3f:ef1/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:67 errors:0 dropped:0 overruns:0 frame:0
            TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:8566 (8.5 KB)  TX bytes:9743 (9.7 KB)

  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:65536  Metric:1
            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Start:  20:55
Finish: 21:05

Задача 3. Установка GUI на TT VM
--------------------------------

Подключить дополнительно Saucy HDD как /dev/sdb

  # apt-get update
  # apt-get dist-upgrade

  The following packages will be upgraded:
    libc-bin libc6 multiarch-support
  3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  Need to get 5,128 kB of archives.
  After this operation, 0 B of additional disk space will be used.

  $ sudo apt-get install gcc automake make vim wget mingetty adduser build-essential libtool flex bison gdb xserver-xorg xfonts-base xinit xterm openbox obconf feh fbpanel rox-filer gnome-icon-theme leafpad elinks xfonts-terminus

  0 upgraded, 351 newly installed, 0 to remove and 0 not upgraded.
  Need to get 141 MB of archives.
  After this operation, 526 MB of additional disk space will be used.

  virtu@trusty:~$ df
  Filesystem     1K-blocks    Used Available Use% Mounted on
  /dev/sda1        6576664 1601616   4617928  26% /
  none                   4       0         4   0% /sys/fs/cgroup
  udev              763004       4    763000   1% /dev
  tmpfs             154520     392    154128   1% /run
  none                5120       0      5120   0% /run/lock
  none              772584       0    772584   0% /run/shm
  none              102400       0    102400   0% /run/user
  virtu@trusty:~$ sudo apt-get clean
  virtu@trusty:~$ df
  Filesystem     1K-blocks    Used Available Use% Mounted on
  /dev/sda1        6576664 1412912   4806632  23% /
  none                   4       0         4   0% /sys/fs/cgroup
  udev              763004       4    763000   1% /dev
  tmpfs             154520     392    154128   1% /run
  none                5120       0      5120   0% /run/lock
  none              772584       0    772584   0% /run/shm
  none              102400       0    102400   0% /run/user
  virtu@trusty:~$

  $ cd ~
  $ cp /mnt/sdb1/usr/local/bin/* .
  $ cp /mnt/sdb1/home/virtu/.Xdefaults .
  $ cat .Xdefaults

  xterm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)
  XTerm*background:     black
  XTerm*foreground:     green
  XTerm*faceName:       terminus
  XTerm*faceSize:       16
  XTerm*geometry:       90x32
  XTerm*rightScrollBar: true
  XTerm*ScrollBar:      true

  $ mkdir src; cp -r /mnt/sdb1/home/virtu/src .
  $ mkdir .config; mkdir .config/openbox; cp /mnt/sdb1/home/virtu/.config/openbox/* .config/openbox

Still 640x480, guest additions install seems to be the only solution

Started: 21:05
Interrupted: 21:50

  # mkdir -p /opt/png
  # cp /mnt/sdb1/opt/png/* /opt/png
  # cd /home/virtu
  # wget https://dl.google.com/linux/direct \
               /google-chrome-stable_current_i386.deb
  # dpkg -i google-chrome-stable_current_i386.deb
  # apt-get -f install
  # rm google-chrome-stable_current_i386.deb
  # vi ~/.config/fbpanel/default
  ...
  Plugin {
      type = launchbar
      config {
          button {
              icon = file-manager
              tooltip = File Manager
              action = rox
          }
          button {
              icon = terminal
              tooltip = Terminal
              action = xterm # x-terminal-emulator
          }
          button {
              image = /opt/google/chrome/product_logo_22.png
              tooltip = Web Browser
              action = x-www-browser
          }
          button {
              image = /opt/png/kxus.png
              tooltip = US keyboard
              action = kxus
          }
          button {
              image = /opt/png/kxru.png
              tooltip = RU keyboard
              action = kxru
          }
          button {
              image = /opt/png/kxee.png
              tooltip = EE keyboard
              action = kxee
          }
      }
  }
  ...

ToDo: Boot invisible ("Ubuntu 14.04" skinned)

Sevenzipping achieved result..

------------------------------------------------------------------------

Задача 3. Установка последних обновлений
----------------------------------------

  # apt-get install update-manager
  ...
  127 MB  will be installed.

  # update-manager -d
  ERROR:root:Could not find any typelib for Dbusmenu
  ERROR:root:Could not find any typelib for Unity
  WARNING:root:can not import unity GI cannot import name 'Dbusmenu'

  (update-manager:5001): dconf-WARNING **: failed to commit changes to dconf: Failed to execute child process "dbus-launch" (No such file or directory)
  warning: could not initiate dbus
  Updated software issued..
  10.9 MB will be installed.

  # lsb_release -a
  No LSB modules are available.
  Distributor ID: Ubuntu# apt-get remove
  Description:    Ubuntu 14.04 LTS
  Release:        14.04
  Codename:       trusty

after E4H:
1693308   4526236
  # apt-get remove update-manager
  # apt-get autoremove
  # apt-get clean all
  # dd if=/dev/zero of=biig; rm -f biig; init 0
1505036   4714508

Sevenzipping achieved result.. 360MB

------------------------------------------------------------------------

Appendix 0. Trusty Tahr vi /etc/udev/rules.d/README

The files in this directory are read by udev(7) and used when events
are performed by the kernel.  The udev daemon watches this directory
with inotify so that changes to these files are automatically picked
up, for this reason they must be files and not symlinks to another
location as in the case in Debian.

Packages do not generally install rules here, this directory is for
local rules.  If you want to override behaviour of package-supplied
rules, which can be found in /lib/udev/rules.d, you can do one of
two things:

 1) Write your own rules in this directory that assign the name,
    symlinks, permissions, etc. that you want.  Pick a number higher
    than the rules you want to override, and yours will be used.

 2) Copy the file from /lib/udev/rules.d and edit it here; you
    should generally only do this if you want to prevent a program
    from being run.

If the ordering of files in this directory are not important to you,
it's recommended that you simply name your files "descriptive-name.rules"
such that they are processed AFTER all numbered rules in both this
directory and /lib/udev/rules.d and thus override anything set there.

------------------------------------------------------------------------

Appendix A. (Virtual Box 4.3.10r93012 Help file):

Virtual Box -> Network -> Adapter -> NAT Network
------------------------------------------------

6.4. Network Address Translation Service (experimental)

The Network Address Translation (NAT) service works in a similar way to a home router, grouping the systems using it into a network and preventing systems outside of this network from directly accessing systems inside it, but letting systems inside communicate with each other and with systems outside using TCP and UDP over IPv4 and IPv6.

A NAT service is attached to an internal network. Virtual machines which are to make use of it should be attached to that internal network. The name of internal network is chosen when the NAT service is created and the internal network will be created if it does not already exist. An example command to create a NAT network is:

  VBoxManage natnetwork add -t nat-int-network -n "192.168.15.0/24" -e

Here, "nat-int-network" is the name of the internal network to be used and "192.168.15.0/24" is the network address and mask of the NAT service interface. By default in this static configuration the gateway will be assigned the address 192.168.15.1 (the address following the interface address), though this is subject to change. To attach a DHCP server to the internal network, we modify the example as follows:

  VBoxManage natnetwork add -t nat-int-network -n "192.168.15.0/24" -e -h on

or to add a DHCP server to the network after creation:

  VBoxManage natnetwork modify -t nat-int-network -h on

To disable it again, use:

  VBoxManage natnetwork modify -t nat-int-network -h off

DHCP server provides list of registered nameservers, but doesn't map servers from 127/8 network.

To start the NAT service, use the following command:

  VBoxManage natnetwork start -t nat-int-network

If the network has a DHCP server attached then it will start together with the NAT network service.

  VBoxManage natnetwork stop -t nat-int-network

stops the NAT network service, together with DHCP server if any.

To delete the NAT network service use:

  VBoxManage natnetwork remove -t nat-int-network

This command does not remove the DHCP server if one is enabled on the internal network.

Port-forwarding is supported (using the "-p" switch for IPv4 and "-P" for IPv6):

  VBoxManage natnetwork modify -t nat-int-network -p "ssh:tcp:[]:10022:[192.168.15.15]:22"

This adds a port-forwarding rule from the host's TCP 10022 port to the port 22 on the guest with IP address 192.168.15.15. To delete the rule, use:

  VBoxManage natnetwork modify -t nat-int-network -p delete ssh

It's possible to bind NAT service to specified interface:

  VBoxManage setextradata global "NAT/win-nat-test-0/SourceIp4" 192.168.1.185

To see the list of registered NAT networks, use:

  VBoxManage list natnetworks


