2014年8月18日月曜日

grub4dos 簡単インスト linuxマウント

 boot openbsd by puppy's grub4dos


HDDにまずopenbsdをいれます。
それからpuppyをいれました。

puppyで fdiskをすると

# fdisk /dev/sda
Command (m for help): p

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008579c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    10487807     5242880   83  Linux
/dev/sda2        10487808    55830527    22671360   83  Linux
/dev/sda3        55830528    78140159    11154816   a6  OpenBSD

となってます。

/dev/sda1 に puppyがいて
/dev/sda2 は ext2 ファイルシステムで ここはpuppyからもopenbsdからも読み書きをできるようにしていきます。


puppy はgrub4dosで openbsdを起動するのですが、
そのファイルは
sda1にある menu.lst で以下で

title OpenBSD
      chainloader (hd0,2)+1
      rootnoverify (hd0,2)
        boot


難所はopenbsdで /dev/sda2 (ext2)を読み書きできるようにすることです。
まず普通に
すると

# disklabel wd0
 #                size           offset  fstype [fsize bsize  cpg]
  a:         19426368         56886176  4.2BSD   2048 16384    1 # /
  b:          1055637         55830528    swap                   # none
  c:         78140160                0  unused                   

だけで、 ext2 がでてきません。

つまり openbsdは後からいれた ext2を認識してません。
それには disklabel -e
で編集する作業が必要になります。

まず fdisk wd0      をして
            
Disk: wd0       geometry: 4864/255/63 [78140160 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 83      0  32  33 -    652 213   9 [        2048:    10485760    ]   Linux files*
 1: 83    652 213  10 -   3475  73  54 [    10487808:    45342720  ] Linux files*
 2: A6   3475  73  55 -   4863 254  63 [    55830528:    22309632  ] OpenBSD   
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused  
なので 

10487808:    45342720 
とを覚えておきます。

それから
disklabel -e wd0 すると viによる編集モードに入ります。

そこで
# /dev/rwd0c:
type: ESDI
disk: ESDI/IDE disk
label: TOSHIBA MK4032GA
duid: 4ad4d11d7894f655
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 4864
total sectors: 78140160
boundstart: 55830528
boundend: 78140160
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:         19426368         56886176  4.2BSD   2048 16384    1 # /
  b:          1055637         55830528    swap                   # none
  c:         78140160                0  unused
  o:         45342720         10487808  ext2fs



とします。
すると

 mount_ext2fs /dev/wd0o /EXT2
でマウントできます。

 あるいは
 cat /etc/fstab                                                              
4ad4d11d7894f655.b none swap sw
4ad4d11d7894f655.a /           ffs       rw 1 1
/dev/wd0o                 /EXT2/  ext2fs rw 1 1

でも可




2014年8月4日月曜日

openbsd,debianで PXE、Openbsdの NFS, isoのマウント


まず debianでのPXEを書きます

internet
|
|
wifi (Uroad-aero)
192.168.100.254
|
|
dhcp
debian
192.168.11.1
|
|
dhcp
PC



インストールするのものは
tftpd-hpa
isc-dhcp-server
です・

ところで  cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
なので、


/srv/tftp
にファイルをおきます。

そして、
service isc-dhcp-server restart
/etc/init.d/tftpd-hpa restart
で起動します。

cat /etc/default/isc-dhcp-server
INTERFACES="eth0"



 cat /etc/dhcp/dhcpd.conf
#ddns-update-style none;
 option domain-name-servers 192.168.100.254;

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.11.0 netmask 255.255.255.0 {
  range 192.168.11.10 192.168.11.19;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.11.255;
  option routers 192.168.11.1;
  next-server 192.168.11.1;
  filename "pxelinux.0";

}





cd    /srv/tftp

lftp -c "open  ftp.debian.org:/debian/dists/squeeze/main/installer-i386/current/images/netboot ; mirror"


 lftp -c "open  http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/    ; mirror "



これにて
root@debian7:/srv/tftp# ls -ltr
合計 33272
-rw-r--r-- 1 root root 13051253  4月 24 16:46 netboot.tar.gz
-rw-r--r-- 1 root root 20971520  4月 24 16:46 mini.iso
drwxr-xr-x 2 root root     4096  4月 25 01:46 pxelinux.cfg
drwxr-xr-x 3 root root     4096  4月 25 01:46 debian-installer
drwxr-xr-x 4 root root     4096  4月 25 01:50 gtk
drwxr-xr-x 2 root root     4096  4月 27 09:22 xen
-rw-r--r-- 1 root root    26474  7月  8 18:44 pxelinux.0


# du ./
8    ./pxelinux.cfg
8    ./gtk/pxelinux.cfg
8    ./gtk/debian-installer/i386/pxelinux.cfg
32    ./gtk/debian-installer/i386/boot-screens/kde
32    ./gtk/debian-installer/i386/boot-screens/lxde
32    ./gtk/debian-installer/i386/boot-screens/xfce
416    ./gtk/debian-installer/i386/boot-screens
30836    ./gtk/debian-installer/i386
30840    ./gtk/debian-installer
99116    ./gtk
8    ./debian-installer/i386/pxelinux.cfg
32    ./debian-installer/i386/boot-screens/kde
32    ./debian-installer/i386/boot-screens/lxde
32    ./debian-installer/i386/boot-screens/xfce
416    ./debian-installer/i386/boot-screens
23372    ./debian-installer/i386
23376    ./debian-installer
30660    ./xen
186420    ./
な感じです。







それではopenbsd はというと
cd /srv/tftp

 wget http://ftp.openbsd.org/pub/OpenBSD/5.5/i386/pxeboot
 wget http://ftp.openbsd.org/pub/OpenBSD/5.5/i386/bsd.rd


cd /srv/tftp mkdir etc/

cat etc/boot.conf                                                                               
boot tftp:/bsd.rd



ln -s pxeboot pxelinux.0





つまり
/srv/tftp# ls -l
合計 6436
-rw-r--r-- 1 root root 6501415  3月  6 02:19 bsd.rd
drwxr-xr-x 2 root root    4096  8月  9 08:25 etc
-rw-r--r-- 1 root root   80544  3月  6 01:47 pxeboot
lrwxrwxrwx 1 root root       7  8月  9 08:25 pxelinux.0 -> pxeboot

だけです。





openbsd をdebin の PXEサーバーとするは でが、




openbsdでは
すでに
dhcpdも
tftpdもインストールされてます。

状況は

internet
|
|
|
rooter
192.168.1.1
|
|
sis0
openbsd(PXE server)
ne3  192.168.11.1  ---PCMCIA card
|
|
PC *debian

 
cat 
ne3
 


cat 
/etc/dhcpd.conf                                                                             

 

 option  domain-name-servers 192.168.1.1;
subnet 192.168.11.0 netmask 255.255.255.0 {
        option routers 192.168.11.1;
        range 192.168.11.32 192.168.11.33;
        filename        "pxelinux.0";
        next-server 192.168.11.1;
}



cat /etc/rc.conf.local                                                                          
dhcpd_flags=""          #NO  # for normal use: ""


これでdhcpdが動きます。




tftpdを動かす準備です。
mkdir   /tftpboot
cd      /tftpboot
そして
lftp -c "open  ftp.debian.org:/debian/dists/squeeze/main/installer-i386/current/images/netboot ; mirror"




if firemware is needed , look   
     http://qiita.com/harukasan/items/98db5f4639433e5e40d4 .

# paxコマンドがなければインストールしておく
sudo aptitude install pax

mkdir -p /tmp/initrd_firmware
cd /tmp/initrd_firmware

mkdir firmware
wget http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/squeeze/current/firmware.tar.gz
tar -C firmware -zxf firmware.tar.gz
pax -x sv4cpio -s'%firmware%/firmware%' -w firmware | gzip -c >firmware.cpio.gz

# initrd.gzに結合する
cat initrd.gz firmware.cpio.gz > initrd_nonfree.gz



pf.cpnfをすごく一時的に甘くしますが、ここまでへりくだらなくてもよいと思いますが、

  cat /etc/pf.conf                                                                               







ext=sis0

icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0

# to some packet scrubbing
match in all scrub (no-df max-mss 1440)


# Handles NAT for the wireless clients
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)

# Block everything by default
#block log all

# Let all traffic out
pass out quick

# Let all traffic in
# allowing 'gre' is useful to allow PPTP VPN traffic
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state





 




もちろん
more /etc/sysctl.conf  
net.inet.ip.forwarding=1        # 1=Permit forwarding (routing) of IPv4 packets
#net.inet.ip.mforwarding=1      # 1=Permit forwarding (routing) of IPv4 multicast packets



最後に
tftpd  /tftpboot/
をして tftpdを動かせばもうこれでOKです、
 libretto L2では N+電源 で ネットワークインストーラーが たちあがってきます.









OpenBSDのNFSです。

NFSは大変神経質です。
5.5をsnapshotsにあげるとうまくいかなくなります。

まず状況です。

internet
|
sis0
openbsd NFSサーバー
ne3
|
debian

そして openbsdの設定ファイルは
 

 # cat /etc/dhcpd.interfaces                                                  
ne3




# cat /etc/dhcpd.conf      
option  domain-name-servers 192.168.1.1;
subnet 192.168.11.0 netmask 255.255.255.0 {
       option routers 192.168.11.1;
        range 192.168.11.3 192.168.11.7;
}




# cat /etc/pf.conf                                                            

# macros
int_if="ne3"
ext_if="sis0"tcp_services="{ 22, 113 }"
icmp_types="echoreq"

# options
set block-policy return
set loginterface egress
set skip on lo


# match rules
match out on $ext_if inet from !($ext_if:network) to any nat-to ($ext_if:0)


 # filter rules
block in log
pass out quick
antispoof quick for { lo $int_if }
pass in on egress inet proto tcp from any to (ext_if) port $tcp_servicespass in inet proto icmp all icmp-type $icmp_types
pass in on $int_if




http://unix.stackexchange.com/questions/7503/nfs-permissions-and-slow-copy
を参考にして、

openbsdで 
/etc/rc.conf.local を                                                                              portmap_flags=""
mountd_flags=""
nfsd_flags="-tun 4"





そして最大の問題は
http://www.ozzu.com/unix-linux-forum/openbsd-nfs-cannot-export-t56956.html
にならって

 # cat /etc/exports                                                           
 /RW  -alldirs -maproot=tuyosi -network=192.168.11 -mask=255.255.255.0

 /EXT2 -maproot=tuyosi:wheel -network=192.168 -mask=255.255.0.0

/EXT2  -alldirs -maproot=tuyosi -network=192.168 mask=255.255.0.0




昔は
cat /etc/exports
/RW     -mapall=tuyosi:tuyosi  -network=192.168.11 -mask=255.255.255.0
読み書きできる


# /etc/rc.d/mountd reload  <-忘れないために
 


openbsdで
mkdir /EXT2
chown tuyosi  /EXT2
chmod -r 777 /EXT2


そうして
debianから
mount  -t  nfs  192.168.11.1:/EXT2    /mnt
でいけます。



だめ  mount -t nfs -o udp 192.168.1.202:/EXT2 /EXT2
mount.nfs: an incorrect mount option was specified




イメージのマウントは
# vnconfig /dev/vnd1c lupu-528JP.iso
# mount /dev/vnd1c k/

# ls k/
AUTORUN.INF               READMEJA.HTM              initrd.gz                 seamonkey-2.11-ja-1.sfs
PUPPY.ICO                 boot.cat                  lupu_528.sfs              splash.xpm
PUPPYJP.ICO               goffice-lupu-528JP.sfs    menu-advanced.lst         vmlinuz
README.HTM                grldr                     menu.lst




puppy's smb.conf
[global]
message command = /usr/local/bin/LinPopUp "%f" "%m" %s; rm %s
workgroup = puppy-wg
server string = puppy-samba
; hosts allow = 192.168.1. 192.168.2.0./24 192.168.3.0/255.255.255.0 127.0.0.1
log file = /var/log.%m
; log level = 1
max log size = 50
security = user
map to guest = Never
dns proxy = no
[-root-SAMBA-]

path = /root/SAMBA
available = yes
browsable = yes
public = yes
writable = yes
guest ok = no

2014年7月13日日曜日

フリーアクセスポイント firmware

http://www.bsdguides.org/2012/a-wireless-access-point-hotspot-using-openbsd/
のとおりですが 解説します。
Linuxとちがって hostapd のような ツールはつかいません。
      ( http://netbuffalo.doorblog.jp/archives/3895783.html)
原理がシンプルです。

まず概要です

インターネット

ルーター
192.168.100.254

|有線

fxp0  (DHCP client) :ありきたりのNIC
OpenBSD
rum0  (DHCPD server):ありきたりのwifi無線子機

|無線

wifiで通信できるPC達


つまり、OpenBSDマシンが PC達にアドレスを出し 、そして natでインターネットにつれだして くれます。

まず natをする pf の firewall です。

 cat /etc/pf.conf
###################
ext=fxp0

icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0

# to some packet scrubbing
match in all scrub (no-df max-mss 1440)

# Handles NAT for the wireless clients
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)

# Block everything by default
block log all

# Let all traffic out
pass out quick

# Let all traffic in
# allowing 'gre' is useful to allow PPTP VPN traffic
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state

これで PC達が firewallを とおりぬけられるようになります。



アドレスを配るため
# cat  /etc/hostname.rum0
cat: /etc/hostname.rum0: No such file or directory



/etc/hostname.rum0はつまり ないのです。
これは あと でのべるシェルスクリプトで SSIDをあてていきます。
お楽しみに


 cat /etc/dhcpd.interfaces

rum0




cat /etc/dhcpd.conf
option  domain-name "my.domain";
option  domain-name-servers 192.168.100.254;
subnet 192.168.12.0 netmask 255.255.255.0 {
        option routers 192.168.12.1;

        range 192.168.12.2 192.168.12.7;


}



 # cat /etc/hostname.fxp0

dhcp




で問題のシェルスクリプトです。

# cat free-accesspoint.bat
これは SSIDが emi で パスワードなしです。
ifconfig rum0 inet 192.168.12.1 netmask 255.255.255.0 \
media autoselect mediaopt hostap nwid emi \
chan 1 up




# cat id-accesspoint.bat
これは SSIDが aaでパスワードが 123456789で保護されてます。
ifconfig rum0 \
 inet    192.168.12.1   netmask 255.255.255.0 \
media autoselect mediaopt hostap nwid aa \
wpakey 123456789 chan 1 up

以上です。


http://archive09.linux.com/feature/49990のように、
 Configuring a wireless adapter to act as an access point in OpenBSD is a simple matter of creating /etc/hostname.ral0 (replace ral0 with your adapter's interface):

# /etc/hostname.ral0
inet 192.168.2.254 255.255.255.0 NONE  ¥

media autoselect mediaopt hostap mode 11g nwid my_secure ¥
chan 11
and issuing the command
sh /etc/netstart ral0 as root.
を参考にして試みてください。



openbsdは 厳密なので
I-O DATA IEEE802.11n/g/b準拠 300Mbps(規格値) 無線LANアダプター WN-G300UA は、最初はあきまへん。

   なお GW-US54Mini2W rum0はいけてます。      安いバファローのwli-uc-gnmは run0でなにもせずに動きますが熱い。

ただし、 PCIのurtwnは
lftp firmware.openbsd.org:/firmware> cd 5.5
cd: received redirection to `http://firmware.openbsd.org/firmware/5.5/'
cd ok, cwd=/firmware/5.5
lftp firmware.openbsd.org:/firmware/5.5> ls
drwxr-xr-x  --  ..
-rw-r--r--  --  acx-firmware-1.4p4.tgz
-rw-r--r--  --  athn-firmware-1.1p1.tgz
-rw-r--r--  --  bwi-firmware-1.4p3.tgz
-rw-r--r--  --  ipw-firmware-1.3p2.tgz
-rw-r--r--  --  iwi-firmware-3.1p2.tgz
-rw-r--r--  --  iwn-firmware-5.10p0.tgz
-rw-r--r--  --  malo-firmware-1.4p3.tgz
-rw-r--r--  --  otus-firmware-1.0p1.tgz
-rw-r--r--  --  pgt-firmware-1.2p3.tgz
-rw-r--r--  --  radeondrm-firmware-20131002p0.tgz
-rw-r--r--  --  rsu-firmware-1.2p0.tgz
-rw-r--r--  --  uath-firmware-2.0p1.tgz
-rw-r--r--  --  ulpt-firmware-1.0p0.tgz
-rw-r--r--  --  upgt-firmware-1.1p3.tgz
-rw-r--r--  --  urtwn-firmware-1.1p2.tgz
-rw-r--r--  --  uvideo-firmware-1.2p1.tgz
-rw-r--r--  --  wpi-firmware-3.2p1.tgz

して urtwn-firmware-1.1p2.tgz を解凍したものを
/etc/firmwareにコピーするとできると 識者は書いてます。
確かに認識してくれるようになりました。

なお wifi子機については
/usr/share/man/man4/rum.4
/usr/share/man/man4/run.4  
なあたりにいろいろ書かれてます

ここからは  話が混み合ってきます。
少しだけ 創造性を付与します。

上の 0penBSDが 有線と無線のDHCPDサーバーになる場合です。
2つのinterfaceにそれぞれ dhcpdを回す必要があります。

それで
有線の方は openbsd本来のDHCPDにまかせて、

無線の方は isc-dhcp-serverに任せましょう。

そうなると 上の方で有線は

internet
|
|

rouer


sis0 (dhcp client)
opensd rum0(dhcpd server)-----wireless-----
ne3(dhcpd server)

|
|
|wirred


有線は

cat /etc/hostname.ne3                                                                           
inet 192.168.11.1 255.255.255.0

cat /etc/dhcpd.interfaces                                                                       
ne3
 

cat /etc/dhcpd.conf                                                                             
option  domain-name "my.domain";
option  domain-name-servers 192.168.1.1;
subnet 192.168.11.0 netmask 255.255.255.0 {
        option routers 192.168.11.1;

        range 192.168.11.2 192.168.11.7;
}

と 既存のものにまったく手をつけません。

ーーー 

 

無線は

# cat  /etc/hostname.rum0

cat: /etc/hostname.rum0: No such file or directory
つまりなし。


で 無線へのDHCPDは、
 isc-dhcpdを利用します。

 cat /usr/local/share/examples/isc-dhcp/dhcpd.conf

default-lease-time 600;
max-lease-time 7200;
log-facility local7;
# A slightly different configuration for an internal subnet.
subnet 192.168.100.0 netmask 255.255.255.0 {
  range  192.168.100.101 192.168.100.109  ;
  option domain-name-servers 192.168.1.1;
  #option domain-name "internal.example.org";
  option routers 192.168.100.1 ;
  #option broadcast-address 10.5.5.31;
  default-lease-time 600;
  max-lease-time 7200;
}


そうしておいて
/usr/local/sbin/dhcpd   rum0    -cf  /usr/local/share/examples/isc-dhcp/dhcpd.conf
でアドレスを割り当てれる体勢にしておいて
つづいて次のコマンドをうてばいいのではないかと 予想されます。



# cat free-accesspoint.bat
これは SSIDが emi で パスワードなしです。
ifconfig rum0 inet 192.168.100.1 netmask 255.255.255.0 \
media autoselect mediaopt hostap nwid emi \
chan 1 up


# cat id-accesspoint.bat
これは SSIDが aaでパスワードが 123456789で保護されてます。
ifconfig rum0 inet 192.168.100.1  netmask 255.255.255.0 \
media autoselect mediaopt hostap nwid aa \
wpakey 123456789 chan 1 up



ここまで進むと OpenBSDのTheoの元で統制のとれた すっきりとしたOSの整然としたシンプルで美しい姿が見えてきます。
おそらく 進んでいくと linuxを openbsdが抜いてしまうかもしれません。
足元の安定度合いの差です。
砂上の楼閣。

コンパイルしておもったのは 腕のいい良い大工の親方をたくさん連れていなければ家がたつのが遅いと思いました。
CPUが親方で メモリがその弟子 ってかんじでしょうか


これからは今までかいてたものの証明にあたります。
全体はつぎです


internet
|
|wireless
|
Uroad-aero
192.168.100.254
|
|wireless
|
run0
OpenBSD (live USB 2GB) bge0(192.168.11.1)----wired LAN----PC
rum0 (WIFI free access point)
|
|woreless
|
PC

つまりOpenBSD (live USB 2GB) は
2つのdhcpdをまわします。
1つは openbsd本来のdhcpdと もう一つは上に述べた iscのdhcpdです・

 openbsd本来のdhcpdほうは

cat /etc/dhcpd.interfaces
run0


cat /etc/dhcpd.conf
option  domain-name "my.domain";
option  domain-name-servers 192.168.100.254;
#.3, 192.168.1.5;
subnet 192.168.11.0 netmask 255.255.255.0 {
        option routers 192.168.11.1;
        range 192.168.11.2 192.168.11.7;
}




iscのdhcpdはスクリプトで後でまわします。
で これは後述します。



他の設定ファイルは
cat /etc/hostname.run0
nwid URoad-662EA0
wpakey 0271
dhcp
 


cat /etc/hostname.bge0
inet 192.168.11.1 255.255.255.0


cat /etc/hostname.rum0
inet 192.168.200.1 255.255.255.0 NONE \
media autoselect mediaopt hostap mode 11g nwid myFreeAP \
chan 1
 

それから cat /etc/pf.conf
ext=run0

icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0

# to some packet scrubbing
match in all scrub (no-df max-mss 1440)

# Handles NAT for the wireless clients
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)

# Block everything by default
block log all

# Let all traffic out
pass out quick

# Let all traffic in
# allowing 'gre' is useful to allow PPTP VPN traffic
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state





こうしてから

 cat /root/free-ISC.batB
/usr/local/sbin/dhcpd rum0 -cf /usr/local/share/examples/isc-dhcp/dhcpd.conf

のスクリプトをまわすと free wifi acsess pointができます。

なお
cat  /usr/local/share/examples/isc-dhcp/dhcpd.conf
 

#option domain-name "example.org";
option domain-name-servers 192.168.100.254;
#ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
# This is a very basic subnet declaration.
subnet 192.168.200.0 netmask 255.255.255.0 {
  range 192.168.200.10 192.168.200.20;
  option routers 192.168.200.1;
}


です。



 /usr/local/sbin/dhcpd rum0 -cf /usr/local/share/examples/isc-dhcp/dhcpd.conf
 する前は

  ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        priority: 0
        groups: lo
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet 127.0.0.1 netmask 0xff000000
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:1e:c9:05:78:fc
        priority: 0
        media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
        status: active
        inet 192.168.11.1 netmask 0xffffff00 broadcast 192.168.11.255
        inet6 fe80::21e:c9ff:fe05:78fc%bge0 prefixlen 64 scopeid 0x1
enc0: flags=0<>
        priority: 0
        groups: enc
        status: active
urtwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:22:cf:ec:c8:05 <ー以前はrun0でした
        priority: 4
        groups: wlan egress
        media: IEEE802.11 autoselect (OFDM54 mode 11g)
        status: active
        ieee80211: nwid URoad-662EA0 chan 2 bssid 00:1d:93:66:2e:a0 178dB wpakey 0x80d48807c087a4cacbbc320ae43060ea4968c557eb3617f79938b64814467a82 wpaprotos wpa1,wpa2 wpaakms psk wpaciphers tkip,ccmp wpagroupcipher tkip
        inet6 fe80::222:cfff:feec:c805%urtwn0 prefixlen 64 scopeid 0x4
        inet 192.168.100.104 netmask 0xffffff00 broadcast 192.168.100.255
rum0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:22:cf:01:22:6f
        priority: 4
        groups: wlan
        media: IEEE802.11 autoselect mode 11g hostap
        status: active
        ieee80211: nwid my_FreeAP chan 1 bssid 00:22:cf:01:22:6f 100dBm
        inet 192.168.200.1 netmask 0xffffff00 broadcast 192.168.200.255
        inet6 fe80::222:cfff:fe01:226f%rum0 prefixlen 64 scopeid 0x5
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33192
        priority: 0
        groups: pflog



 /usr/local/sbin/dhcpd rum0 -cf /usr/local/share/examples/isc-dhcp/dhcpd.conf
すると
 Internet Systems Consortium DHCP Server 4.2.5-P1
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
/var/db/dhcpd.leases line 2: Time zone offset or semicolon expected.
        starts 6 2014/07/19 05:16:10 UTC;
                                      ^
/var/db/dhcpd.leases line 3: Time zone offset or semicolon expected.
        ends 6 2014/07/19 17:16:10 UTC;
                                    ^
lease 192.168.11.2: no subnet.
/var/db/dhcpd.leases line 9: Time zone offset or semicolon expected.
        starts 6 2014/07/19 05:25:35 UTC;
                                      ^
/var/db/dhcpd.leases line 10: Time zone offset or semicolon expected.
        ends 6 2014/07/19 17:25:35 UTC;
                                    ^
lease 192.168.11.2: no subnet.
Wrote 0 leases to leases file.
Listening on BPF/rum0/00:22:cf:01:22:6f/192.168.200.0/24
Sending on   BPF/rum0/00:22:cf:01:22:6f/192.168.200.0/24
Sending on   Socket/fallback/fallback-net

なメッセージがでて

ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        priority: 0
        groups: lo
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet 127.0.0.1 netmask 0xff000000
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:1e:c9:05:78:fc
        priority: 0
        media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
        status: active
        inet 192.168.11.1 netmask 0xffffff00 broadcast 192.168.11.255
        inet6 fe80::21e:c9ff:fe05:78fc%bge0 prefixlen 64 scopeid 0x1
enc0: flags=0<>
        priority: 0
        groups: enc
        status: active
urtwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:22:cf:ec:c8:05
        priority: 4
        groups: wlan egress
        media: IEEE802.11 autoselect (OFDM54 mode 11g)
        status: active
        ieee80211: nwid URoad-662EA0 chan 2 bssid 00:1d:93:66:2e:a0 178dB wpakey 0x80d48807c087a4cacbbc320ae43060ea4968c557eb3617f79938b64814467a82 wpaprotos wpa1,wpa2 wpaakms psk wpaciphers tkip,ccmp wpagroupcipher tkip
        inet6 fe80::222:cfff:feec:c805%urtwn0 prefixlen 64 scopeid 0x4
        inet 192.168.100.104 netmask 0xffffff00 broadcast 192.168.100.255
rum0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:22:cf:01:22:6f
        priority: 4
        groups: wlan
        media: IEEE802.11 autoselect mode 11g hostap
        status: active
        ieee80211: nwid my_FreeAP chan 1 bssid 00:22:cf:01:22:6f 100dBm
        inet 192.168.200.1 netmask 0xffffff00 broadcast 192.168.200.255
        inet6 fe80::222:cfff:fe01:226f%rum0 prefixlen 64 scopeid 0x5
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33192
        priority: 0
        groups: pflog

になります。

一応xdmは動かしてます。 

 pkg_infoは
bzip2-1.0.6p0       block-sorting file compressor, unencumbered
gettext-0.18.2p4    GNU gettext
isc-dhcp-server-4.2.5.1p0 ISC DHCP Server
lftp-4.4.10         shell-like command line ftp and sftp client
libiconv-1.14p1     character set conversion library
libidn-1.28p0       internationalized string handling
nano-2.2.6          Pico editor clone with enhancements
pcre-8.33           perl-compatible regular expression library
quirks-1.113        exceptions to pkg_add rules
readline-6.2pl4     library to edit command lines as they are typed in
wget-1.15           retrieve files from the web via HTTP, HTTPS and FTP

ですが、2GのUSBメモリで

xterm -fn  10x20
で動かせば、文字がおおきくなり ktermは不要です。


 ついでに seamonkey anthy ibus ibus-anthyもいれました。
rootだけでログインするつもりなので
cat /root/.xsession
cat: /root/.xsession: No such file or directory
ないのです。
でも 
terminalで
/usr/local/bin/ibus-daemon -d -x -r
したら 日本語入力可能です。
これで 2Gのメモリで
df
Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/sd1a      3571580   2350500   1042504    69%    /

load averages:  0.12,  0.31,  0.49                       hoo.my.domain 06:53:07
50 processes: 49 idle, 1 on processor
CPU states:  0.0% user,  0.0% nice,  0.0% system, 32.9% interrupt, 67.1% idle
Memory: Real: 163M/326M act/tot Free: 157M Cache: 96M Swap: 0K/133M
の負荷です。



わずか 2GBのUSBメモリで openBSDがうごき
有線の nat箱と
無線の wifiアクセスポイントをかねてくれてます。
ちょっと OpenBSD凄いです。





2014年7月5日土曜日

ubuntu と openbsd との  dual boot

まず openbsdをいれました。

それから HDDを増設して このsdbに ubuntu
をいれました。
btdownloadcurses   hoge.iso.torrent
このとき grubは sdbにしました。
openbsdのあるsdaにlinux固有のgrubがはいるとは思えないからでした。



すると 再起動時に openbsdが立ち上がってきました。
そのため PC内部のケーブルを交換しました。

そうすると sdaがubuntuになりました。
こうなると ubuntuしか立ち上がりません。


http://www.kariliq.nl/openbsd/grub2.html
をみて
  cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "OpenBSD" {
set root=(hd1,4)
chainloader +1
}

 して、


update-grub これで dual boot になりました。
 
一応 diff grub.cfg grub.cfg-origin すると
  diff grub.cfg grub.cfg-origin 
67c67
< set root='hd0,msdos1'
---
> set root='hd1,msdos1'
69c69
<   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
---
>   search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
141c141
<  set root='hd0,msdos1'
---
>  set root='hd1,msdos1'
143c143
<    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
---
>    search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
158c158
<   set root='hd0,msdos1'
---
>   set root='hd1,msdos1'
160c160
<     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
---
>     search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
175c175
<   set root='hd0,msdos1'
---
>   set root='hd1,msdos1'
177c177
<     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
---
>     search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
198c198
<  set root='hd0,msdos1'
---
>  set root='hd1,msdos1'
200c200
<    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
---
>    search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
209c209
<  set root='hd0,msdos1'
---
>  set root='hd1,msdos1'
211c211
<    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
---
>    search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  9074c8b6-4684-4af2-9771-8bc244b70c95
230,234d229
< 
< menuentry "OpenBSD" {
< set root=(hd1,4)
< chainloader +1
< }
236,241d230
< 
< ### BEGIN /etc/grub.d/40_custom-origin ###
< # This file provides an easy way to add custom menu entries.  Simply type the
< # menu entries you want to add after this comment.  Be careful not to change
< # the 'exec tail' line above.
< ### END /etc/grub.d/40_custom-origin ###
 これはとても手での修正は無理です。
 ubuntu重い。
 
 なお ubuntuではtop - 19:10:44 up 34 min,  3 users,  load average: 1.32, 0.79, 0.73
Tasks: 171 total,   3 running, 168 sleeping,   0 stopped,   0 zombie
%Cpu(s): 63.9 us,  1.3 sy,  0.0 ni, 34.6 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st
KiB Mem:   2049988 total,  1397296 used,   652692 free,    80632 buffers
KiB Swap:  4819496 total,        0 used,  4819496 free.   583900 cached Mem
 
 でで このPCでは 2CPUであるけど それがやられてないんですね。
こここは openbsdの bsd.mpの multi processor のほうがすごい。
 



openbsdでは
load averages:  0.25,  0.06,  0.02                     amd64.my.domain 19:17:29
23 processes: 22 idle, 1 on processor
CPU0 states:  0.0% user,  0.0% nice,  0.0% system,  0.0% interrupt,  100% idle
CPU1 states:  0.2% user,  0.0% nice,  0.0% system,  0.0% interrupt, 99.8% idle
Memory: Real: 11M/58M act/tot Free: 1919M Cache: 17M Swap: 0K/2288M
と各々のSPUにわけてことがはこんでいる。
CPU 1個から 2個への入れ替えの時も
cp /bsd /bsd.sp
mc /bsd.mp /bsd
そして再起動だけですむ。
なにか凄くない?


 
 
 

2014年6月22日日曜日

OpenBSD live USB (USBメモリの上でopenbsd走るよ)

最初にちょっと特殊な openbsdのインストールの話を書きます。
その後 ありきたりにUSBへのインストールに話を戻しますので初めての方はしばらくの辛抱をしてください。

 USBメモリの上の openbsdか puppyかを  openBSDのGRUBで 立ち上げる手法です。
最初にopenbsdをUSBにいれ その後fat32のパーティションをlinuxで作り、そこにpuppyのファイルを起きます。

this is a technique to launch  puppy or openbsd on the USB memory by OpenBSD's GRUB .
first i install openbsd into USB ,and create the partition of  fat32  by linux ,and then put  put the file of puppy there(fat32).

まず 状況ですが USBメモリはopenbsd上では sd1で認識されてます。
USB memory is recognized by sd1 on openbsd .


# fdisk sd1
Disk: sd1       geometry: 3840/255/63 [61702144 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 0C    652 213  10 -   3840 199   7 [    10487808:    51214336 ]  
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused    
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused    
*3: A6      0  32  33 -    652 213   9 [        2048:    10485760 ] OpenBSD

 で Win95 FAT32L  にpuppyのファイルをおいてます。
I have put the file of puppy in Win95 FAT32L.
  

USBから立ち上げたOpenBSDに
pkg_add grub で grubをいれます。
openbsdにもgrubがなんとあるのです。

In OpenBSD that was launched from the USB    I install  grub by  pkg_add grub. there is grub also openbsd.

そして
  cat /grub/menu.lst  
 default 0
 timeout 10

 title OpenBSD in USB
 root (hd0,3)
 chainloader +1

 title Puppy571 in USB
 root (hd0,0)
 kernel /p571/vmlinuz
 initrd /p571/initrd.gz
 boot

 title slacko in USB
 root (hd0,0)
 kernel /slc/vmlinuz
 initrd /slc/initrd.gz
 boot


と hd0 に気をつけてください。

そして 
grub-instal  /dev/sd1c
をして 完成です。

つまり USBは  openbsdでは sd1 ですが、
         (HDDは sd0 ) 
grub ローダーが USBの sd1に入ってる成でしょうか、

grub では hd0に入れ替わってますねえ~



ただし、openbsdをいれてから あとでFATのpartitionを追加したので

# dsiklabel sd1 では FATが見えません!

# disklabel sd1                                                               
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Transcend 32GB 
duid: 82ec76de45b5ee83
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 3840
total sectors: 61702144
boundstart: 2048
boundend: 10487808
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:          9985760           502048  4.2BSD   2048 16384    1 # /
  b:           500000             2048    swap                   # none
  c:         61702144                0  unused                  




NEXT is nomal  openbsd insttall on USB memory .  this is easy .
ここから 普通のUSBメモリーへのopenbsdの話になります。



openbsdを USBメモリにインストールしてdhcpd と firewall(未確認)とを動かす

あとで知ったのだが、
http://www.openbsd.org/faq/faq14.html#flashmemLive
にすでに書かれていた。
It is very easy to create a bootable USB flash (or other!) drive that can be used as a "live" OpenBSD system without installing OpenBSD on the local hard disk of a machine.
とね。
またここにあるのだが、 別にPCのBIOSが USBメモリをしてなくっても大丈夫
自分の場合はHDDに仕込んだdebianのgrubを使って 
OpenBSDを usd HDD 起動させている・



eeBSD8.0 とか linux系であれば ご存知のunetbootin-linux-608.binでlive USBがつくれますが、 openbsdは これでは無理でした。



まず パソコンのCDドライブに openbsd5.5のCD(cd55.isoでつくったもの)をいれ  かつUSB メモリも差し込み パソコンの電源をいれます。そして普通にUSBに インストールをするのですが、インストール先はsd2です。これをsd1にしてしまうと パソコンのハードディスクは 消されてしまうのでくれぐれも注意をしてください。

そうするとUSBメモリスチックから openbsdが 立ち上がります。
動くと感動です。
I insert  both  'openbsd5.5 CD(made with cd55.iso)'  and USB memory  stck , and then  ' well known install process' begin from CD.q
OpenBSD install place is sd2  namely USB .
if this is set to sd1 ,  hard disk of a personal computer  will be completely erased .
Be careful.
Openbsd rises From only USB memory stick .
Good!  Good!  Good!
全体的な状況は  The general situation is next picture .

internet
|
|wireless
|
internet address
wimax (uroad-aero) dhcpd & DNS
192.168.100.254
|
|wireless
|
rum0(wifi USB) wimax published192,168.100.X
openbsd5.5 PC firewall &dhpcd
bge0(wired LAN) fixed address192.168.11.1
|
|LAN cable
|
eth0(wired LAN)openbsd published192,168.11.X
mint linux PC

です。


openbsd5.5で 
dhcpdを動かし mint linuxにアドレスを割り当て
さらに 
openbsd5.5でパケットフィルターpfでファイアウォールを動かし
mint linuxがinternetへ出れるようにします。


By openbsd5.5 , I wont to work dhcpd, so  assign an address to mint linux .
Furthermore I   wont to work packet filter pf in openbsd5.5 , then mint linux can go to internet.

なぜこうしたのかというと、 有線LAN環境を持ってないと
無線LANだけではOS導入の際に苦しいことがおおくなります。
インストール時は無線ドライバーははいってないですよね。

When I was asked  the reason  , I do not have wired internet  LAN environment.
Many OS instllation is  hard  in case of  wireless LAN only .
For example ubuntu linu  ,  wifi   driver is not ready  at the time of the installation.


まず openbsdを USB メモリ からたちあげます。

First of all,  insert USB memory then  openbsd come comes up ant usual openbsd system work .  

openbsdをDHCPDサーバーとしてはたらかす
openbsd as DHCPD

wirelessでつなぐために
To tie openbsd and internet  with wireless  namely wifi ,
I look at http://tobysoft.net/wiki/index.php?OpenBSD%2FDHCP%B4%D8%CF%A2%A4%CE%C0%DF%C4%EA

cat /etc/hostname.rum0
ーーーーーーーーーーー
dhcp nwid URoad-662EA0 wpakey 0460001



 手動で動かしたいときは
 wifi.bat として
              ifconfig rum0 down
              ifconfig rum0 nwid "URoad-662EA0" wpakey "04600071" up
              dhclient rum0


これ以降は 実はmintからopenbsdに sshで入ってから作業します。
コピー&ペーストが使えて楽です。
  
ssh -l hatahata 192.168.100.X
(mintも wifiが入ってるので uroadaeroが mintに 勝手にアドレスを割り当てます。 それがこの192.168.100.Xアドレスです)
で openbsdに mintから入ってます。
Since this time I enters openbsd from mint  with ssh.
Copy & paste can be used and it .
ssh -l hatahata 192.168.100.X
(Because uroadaero allocates the address  for mint.  This is 192.168.100.X address. )
I enters  openbsd from mint by ssh , and  by the right of root I rewrite many file .


1)pkg_addをするために
/root/.profile の最後に
export PKG_PATH=http://ftp.jaist.ac.jp/pub/OpenBSD/5.5/packages/i386/
をつける
add this line to /root/.profile , so pkg_add can be done .


2)dhcpdは有線のbge0で動かすので
cat /etc/hostname.bge0  
----------------------------------
inet 192.168.11.1 255.255.255.0 NONE
 と固定アドレスをあて



3)cat /etc/dhcpd.interfaces
---------------------------------                                                
bge0


4)cat /etc/dhcpd.conf                                                        
---------------------------------------------------------------

option  domain-name-servers 192.168.100.254  ;
subnet 192.168.11.0 netmask 255.255.255.0 {
        option routers 192.168.11.1;
        range 192.168.11.10 192.168.11.11;

}

192.168.100.254はwifiルーターのアドレス



  5)http://www.openbsd.org/faq/faq6.html#DHCPserver をみて
 echo 'dhcpd_flags=""' >>/etc/rc.conf.local

すると openbsd で
# ps -ax | grep dhcp
 21743 ??  Is      0:00.00 /usr/sbin/dhcpd
10115 p0  S+      0:00.00 grep dhcp
 とうごいてる。

  そしてたしかに dhcpクライアント(mint)も
  ifconfig -a
eth0      Link encap:イーサネット  ハードウェアアドレス 00:23:8b:82:4f:19
          inetアドレス:192.168.11.10  ブロードキャスト:192.168.11.255  マスク:255.255.255.0
          inet6アドレス: fe80::223:8bff:fe82:4f19/64 範囲:リンク
          UP BROADCAST RUNNING MULTICAST  MTU:1500  メトリック:1
          RXパケット:274 エラー:0 損失:0 オーバラン:0 フレーム:0
          TXパケット:596 エラー:0 損失:0 オーバラン:0 キャリア:0
          衝突(Collisions):0 TXキュー長:1000
          RXバイト:36817 (36.8 KB)  TXバイト:68328 (68.3 KB)
          割り込み:16
とアドレスをopenbsdからもらってる。



6) つぎは PF パケットフィルターです。

それにはまず

# vi /etc/sysctl.conf
...
net.inet.ip.forwarding=1


http://www.openbsd.org/faq/pf/example1.html#allrules の egrepに惑わされましたが、 openBSD misc mailing list からの たくさんの助言でできました。



cat /etc/pf.conf
# macros
int_if="bge0"
ext_if="rum0"

tcp_services="{ 22, 113 }"
icmp_types="echoreq"

# options
set block-policy return
set loginterface egress
set skip on lo

# FTP Proxy rules
anchor "ftp-proxy/*"
pass in quick on $int_if inet proto tcp to any port ftp divert-to 127.0.0.1 port 8021

# match rules
match out on $ext_if inet from !($ext_if:network) to any nat-to ($ext_if:0)
#()にてアドレスになる。  


 # filter rules
block in log
pass out quick

antispoof quick for { lo $int_if }

pass in on egress inet proto tcp from any to (egress) \
    port $tcp_services
pass in inet proto icmp all icmp-type $icmp_types
pass in on $int_if


pfctl -ss
all tcp 192.168.11.1:22 <- 192.168.11.10:34071       ESTABLISHED:ESTABLISHED
all udp 192.168.11.255:631 <- 192.168.11.10:631       NO_TRAFFIC:SINGLE



pfctl -sr
anchor "ftp-proxy/*" all
pass in quick on bge0 inet proto tcp from any to any port = 21 flags
S/SA divert-to 127.0.0.1 port 8021
match out on rum0 inet from ! (rum0:network) to any nat-to (rum0:0)
block return in log all
pass out quick all flags S/SA
block drop in quick on ! lo inet6 from ::1 to any
block drop in quick on ! lo inet from 127.0.0.0/8 to any
block drop in quick inet from 127.0.0.1 to any
block drop in quick on ! bge0 inet from 192.168.11.0/24 to any
block drop in quick inet from 192.168.11.1 to any
block drop in quick inet6 from ::1 to any
block drop in quick on lo0 inet6 from fe80::1 to any
block drop in quick on bge0 inet6 from fe80::21e:c9ff:fe05:78fc to any
pass in on egress inet proto tcp from any to (egress) port = 22 flags S/SA
pass in on egress inet proto tcp from any to (egress) port = 113 flags S/SA
pass in inet proto icmp all icmp-type echoreq
pass in on bge0 all flags S/SA




puppy linux (dhcp client)
-------------------------------------------
fconfig -a
eth0      Link encap:Ethernet  HWaddr 00:00:39:E3:38:99
          inet addr:192.168.11.10  Bcast:192.168.11.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1711 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1990 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1103913 (1.0 MiB)  TX bytes:313349 (306.0 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  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)


cat /etc/resolv.conf
# Generated by dhcpcd for interface eth0
nameserver 192.168.100.254


ping www.openbsd.org
PING www.openbsd.org (129.128.5.194): 56 data bytes
64 bytes from 129.128.5.194: seq=0 ttl=227 time=311.753 ms
64 bytes from 129.128.5.194: seq=1 ttl=227 time=312.358 ms
^C
--- www.openbsd.org ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 311.753/312.055/312.358 ms



route -e
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.11.0    *               255.255.255.0   U         0 0          0 eth0
169.254.0.0     *               255.255.0.0     U         0 0          0 eth0
127.0.0.0       *               255.0.0.0       U         0 0          0 lo
default         192.168.11.1    0.0.0.0         UG        0 0          0 eth0



それにしても ローカルネットワークからデフォルトルートとして指定されているインタフェースであるegressインタフェースを通るところでNATを行う と書かれているので 信じてしまいました。 これが失敗の原因。 


1)pfctl -f  /etc/pf.conf
をしてルールをロードします。
これで pfctl -sr をすると 以下が出力されます。  
pfctl -s  state (pfctl -ss) もnatを見るにはいい。

         
2)vi で行番号を表示は
 :set nu


結局USBメモリに firefox , anthyをいれました。
http://openbsd-akita.blogspot.jp/2014/06/openbsd-dhcpdpffirewall.html
を見てください。
これでも
$ df
Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/sd1a      2057756     87964   1866908        4%    /
/dev/sd1k     26039612    166256  24571376     1%    /home
/dev/sd1d      4074524        20   3870780           0%    /tmp
/dev/sd1f      4122108    690312   3225692      18%    /usr
/dev/sd1g      2057756    367104   1587768     19%    /usr/X11R6
/dev/sd1h      8917948   1441560   7030492    17%    /usr/local
/dev/sd1j      4122108         4   3916000             0%    /usr/obj
/dev/sd1i      3018236         4   2867324             0%    /usr/src
/dev/sd1e      6387260     16980   6050920        0%    /var
と余裕がありますね。



しかし段々2Gではきつくなってきます。
それで 32Gを買いました。
openbsd miscに投稿したのですが

1) openbsdのfdiskはつかいにくいので linuxでします。
use linux (because openbsd fdisk is hard to use)
by fdisk , make /dev/sdb4  Id:a6

2) 「openbsdのinstallboot」命令がうまくいかないので 以下で回避します。
 インストール用のOPENBSD5.5 i386 CDを linuxマシンにさし
これでbootして最短のインストールをおこないます。
これで回避します。   
then use  'openbsd5.5 install CD disk' for <<installboot>>
on  installing   OpenBSD
        use  OpenBSD area  <- 1)
        mount point /  (because original USB has a and b only)
        install  bsd,  bsd.rd,   base55 only

3)それから コピー元のUSBをさきに openbsdの走ってるマシンamd64にさします。
その後 コピー先のUSBをさします。 
すると dmesgにて 元がsd0 先がsd1と認識されてます。 
then openbsd runninng machine,

# mkdir /mnt0
# mkdir /mnt1

# mount /dev/sd0a /mnt0  <- / partition
# mount /dev/sd1a /mnt   <- / partition

# (cd /mnt0; tar cvpf - .)|(cd /mnt1 ; tar xpf -)
#umount /mnt0 => cannot
#umount /mnt1 => cannot

so halt openbsd machine ,

4)then goto linux machine

fdisk /dev/sdb

  make bootable flag on sdb4
最初に bootable flagをつえとけばよかったと思われる。
  ( if 1) has this proceidure , this may be needless )

---
this method is perhaps effective to smaller USB clone , or
USB to Hard disk clone and so so .