2015年3月14日土曜日

Raspbianのメモ 2回目

どうも、VPNが張れない。

ルータまでは届くんだが、その先へ転送していないようだ。

ということで、OpenswanのをやめてSoftEther VPNでいくことにする。

その前に自動起動を解除しておく

$ sudo sysv-rc-conf ipsec off
$ sudo sysv-rc-conf xl2tpd off

ここを参考にいじくる。

bridge-utilsのインストール

$ sudo aptitude install bridge-utils

$ sudo vi /etc/network/interfaces

以下を付けたし
auto br0
iface br0 inet static
        address 192.168.1.3
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        bridge_ports eth0
        #pre-up brctl addbr br0
        #brctl addif eth0

今回は運用ベースなのでbetaではなくRTMで動かすようにする。
ここから、wgetでもってくる。

$ sudo wget http://jp.softether-download.com/files/softether/v4.08-9449-rtm-2014.06.08-tree/Linux/SoftEther%20VPN%20Server/32bit%20-%20ARM%20EABI/softether-vpnserver-v4.08-9449-rtm-2014.06.08-linux-arm_eabi-32bit.tar.gz

展開,展開先ディレクトリ,make

$ tar zxvf softether-vpnserver-v4.08-9449-rtm-2014.06.08-linux-arm_eabi-32bit.tar.gz
$ cd vpnserver
$ sudo make

vpnserverを/usr/local/に移動する。圧縮ファイルも削除する。

$ cd ..
$ sudo mv vpnserver /usr/local
$ sudo rm softether-vpnserver-v4.08-9449-rtm-2014.06.08-linux-arm_eabi-32bit.tar.gz

インストール先へ移動し、パーミッションをroot権限のみに変更する

$ cd /usr/local/vpnserver/
$ sudo chmod 600 *
$ sudo chmod 700 vpncmd
$ sudo chmod 700 vpnserver

VPN serverがきちんと動くかの確認。後のプロンプトは3→check。問題なければexit。

$ sudo /usr/local/vpnserver/vpncmd

スタートアップスクリプトへの登録。/etc/init.d/vpnserverを新規に作成する。
$ sudo vi /etc/init.d/vpnserver


#!/bin/sh
### BEGIN INIT INFO
# Provides:                     vpnserver
# Required-Start:               $local_fs $network
# Required-Stop:                $local_fs $network
# Default-Start:                2 3 4 5
# Default-Stop:                 0 1 6
# Short-Description:            SoftEther VPN 1.0 RC2
# Description:                  Start vpnserver daemon SoftEther VPN 1.0 Server
### END INIT INFO


DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/vpnserver


. /lib/lsb/init-functions


test -x $DAEMON || exit 0


case "$1" in
start)
sleep 3
log_daemon_msg "Starting SoftEther VPN 1.0 Server" "vpnserver"
$DAEMON start >/dev/null 2>&1
touch $LOCK
log_end_msg 0
sleep 3


;;


stop)
log_daemon_msg "Stopping SoftEther VPN 1.0 Server" "vpnserver"
$DAEMON stop >/dev/null 2>&1
rm $LOCK
log_end_msg 0
sleep 2


;;


restart)
$DAEMON stop
sleep 2


$DAEMON start
sleep 5


;;


status)
    if [ -e $LOCK ]
    then
        echo "vpnserver is running."
    else
        echo "vpnserver is not running."
    fi
;;
*)


echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0


実行権限を与える。


$ sudo chmod +x /etc/init.d/vpnserver


自動実行を入れる。


$ sudo sysv-rc-conf vpnserver on
$ sudo sysv-rc-conf --list vpnserver
vpnserver    2:on       3:on    4:on    5:on

$ sudo service vpnserver start
SoftEther VPNの設定をウィンドウズ側で行う。

後は、


ここを参考に作成。

2015年3月13日金曜日

Raspbianのメモ

とりあえず、SD焼くまではOK

で、ブートするとraspi-configが立ち上がるので
Advancesd Options-update
Expand Filesystem  ルートパーティションを拡張
ここで再起動

Internationalisatin Options-Change Keyboard Layout でキーボード選択
Change User Password でパスワード設定
Internationalisatin Options-Change timezone タイムゾーンを設定

Advancesd OptionsでSSHを起動するようにする。

$ sudo aptitude update
$ sudo aptitude safe-upgrade

$ sudo aptitude install ttf-kochi-gothic xfonts-intl-japanese xfonts-intl-japanese-big xfonts-kaname
raspi-config でchange_localeをja_JP.UTF-8を選択しておく。
$ sudo aptitude install vim
raspi-config でさらに設定しておく
Advancesd Options
 HostNameで名前を変えておく。
 Memory Splitを最低にしておく。(GUIは使わない。)
ここでreboot
あと、こいつはDNSやDHCPサーバとして使うので、静的IPにする。
$ sudo vi /etc/network/interfaces
iface eth0 inet dhcp
となっているのを以下に書き換え
iface eth0 inet static
  address 192.168.1.2
  network 192.168.1.0
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.1
これで固定されたので、NTPの設定
$ sudo vi /etc/ntp.conf
#server 0.debian.pool.ntp.org iburst
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst
pool ntp1.eonet.ne.jp iburst
pool ntp2.eonet.ne.jp iburst
$ sudo service ntp restart
$ ntpq -p
これで同期が取れていたらOK
あとは、ここを参考にdnsmasqを設定する。
$ sudo aptitude install dnsmasq
$ sudo vi /etc/dnsmasq.conf
で以下のコメントアウトを解除する。
#conf-file=/etc/dnsmasq.more.conf
conf-file=/etc/dnsmasq.more.conf
$ sudo vi /etc/dnsmasq.more.conf
domain-needed
bogus-priv

# LAN内で使用するドメインを指定。
# このドメインに対する正引き要求は、
# 1. /etc/hosts
# 2. dnsmasq のDHCP機能によって割り当てられたIPアドレス
# のみを検索して応答する。
local=/hoge.local/

# 正引き要求に対して /etc/hosts 内にあるホスト名を回答するとき、
# ホスト名の末尾に下記で設定されたドメイン名を付加して応答する。
expand-hosts

# ドメイン名の指定。
# このドメイン名は以下のように利用される。
# 1. "expand-hosts" を設定した場合に付加されるドメイン名
# 2. DHCPクライアントが取得するドメイン名
domain=hoge.local

# DHCPクライアントへ割り当てるIPアドレスの範囲とリース時間の指定。
# このオプションを設定するとDHCPサーバ機能が有効となる。
dhcp-range=192.168.1.10,192.168.1.80,12h

# DHCPクライアントに通知するルータ、DNSサーバ、NTPサーバの指定。
# 今回は、DNS, NTPサーバとして自身を指定する。
# NTPサーバの設定が必要。 (/etc/ntp.conf)
dhcp-option=option:router,192.168.1.1
dhcp-option=option:netmask,255.255.255.0
dhcp-option=option:dns-server,192.168.1.2
dhcp-option=option:ntp-server,192.168.1.2
続いて、hostファイルの編集と、リゾルバの変更
$ sudo vi /etc/host.conf
以下のようになってなかったらしておく。
order hosts,bind
multi on

$ sudo vi /etc/resolv.con

nameserver 127.0.0.1 <- local DNS
nameserver 192.168.1.2 <- local DNS
nameserver 8.8.8.8  <- GoogleパブリックDNSサーバー
nameserver 8.8.4.4  <- GoogleパブリックDNSサーバー2

$ sudo vi /etc/hosts

127.0.1.1       raspi01 これはDHCPの時に勝手に書かれた行なので消す。
192.168.1.2     raspi01

必要なIPを記述したら再始動
$ sudo service dnsmasq restart
これで、DHCPとDNSが稼働した。

再起動時も起動するようにsysv-rc-confを使ってコントロールします。
$ sudo aptitude install sysv-rc-conf
$ sudo sysv-rc-conf --list
$ sysv-rc-conf --list dnsmasq
dnsmasq      0:off      1:off   2:on    3:on    4:on    5:on    6:off
OK
とりあえずは、これで最低限動くようにはなった。
次に、DDNS入れとく。
利用するのはddclient。
$ sudo aptitude install ddclient
$ sudo vi /etc/ddclient.conf

daemon=1800
syslog=yes
ssl=no

protocol=dyndns2
use=web
server=dynupdate.no-ip.com
login=
password=
hostname.no-ip.com
これでテスト。

$ sudo ddclient -daemon=0 –verbose


うまくいったら
$ sudo service ddclient start


自動起動するように
$ sudo sysv-rc-conf ddclient on
$ sudo sysv-rc-conf --list ddclient
ddclient     1:off      2:on    3:on    4:on    5:on


OK


最後はVPN環境を作る。ここを参考にした。
$ sudo aptitude install lsof openswan xl2tpd


openswanが証明書を聞いてくるが、”いいえ”で


$ sudo vi /etc/sysctl.conf
以下を追記

##############################################################
# VPN
net.ipv4.ip_forward=1
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.default.send_redirects=0
net.ipv4.conf.default.accept_redirects=0
net.ipv4.conf.eth0.send_redirects=0
net.ipv4.conf.eth0.accept_redirects=0
net.ipv4.conf.lo.send_redirects=0
net.ipv4.conf.lo.accept_redirects=0
反映
$ sudo  sysctl -p

Openswanを修正
$ sudo vi /etc/ipsec.conf
最後あたりに以下を追記
conn L2TP
keyingtries=0
type=transport
compress=yes
authby=secret
forceencaps=yes
pfs=no
auto=add
ike=aes-sha1;modp3072
phase2=esp
phase2alg=aes-sha1;modp3072
rekey=no
salifetime=3h
ikelifetime=1h
left=192.168.1.2 # Raspberry PiのIPアドレスにする
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
事前共有キーの生成
$ sudo vi /etc/ipsec.secrets
以下を追記
%defaultroute %any : PSK "hogehoge"
サービスを再起動
$ sudo service ipsec restart
チェックしてFAILEDがないことを確認。

$ sudo ipsec verify
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path                                 [OK]
Linux Openswan U2.6.37/K3.18.9+ (netkey)
Checking for IPsec support in kernel                            [OK]
SAref kernel support                                           [N/A]
NETKEY:  Testing XFRM related proc values                      [OK]
        [OK]
        [OK]
Checking that pluto is running                                  [OK]
Pluto listening for IKE on udp 500                             [OK]
Pluto listening for NAT-T on udp 4500                          [OK]
Checking for 'ip' command                                       [OK]
Checking /bin/sh is not /bin/dash                               [WARNING]
Checking for 'iptables' command                                 [OK]
Opportunistic Encryption Support                                [DISABLED]


xl2tpdの設定
$ sudo vi /etc/xl2tpd/xl2tpd.conf


[global]
port = 1701


[lns default]
ip range = 192.168.1.121 - 192.168.1.123
local ip = 192.168.1.2
length bit = yes
refuse chap = yes
require authentication = yes
pppoptfile = /etc/ppp/l2tpd.pppopt


サービスの再起動
$ sudo service xl2tpd restart


pppoptの編集


$ sudo vi /etc/ppp/l2tpd.pppopt

mtu 1420
mru 1420
asyncmap 0
auth
crtscts
lock
modem
debug
proxyarp
lcp-echo-interval 180
lcp-echo-failure 3


refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2


ms-dns 192.168.1.1


ppp用のパスワードを設定。
$ sudo vi /etc/ppp/chap-secrets
UserName * Password *


自動起動するように
$ sudo sysv-rc-conf ipsec on
$ sudo sysv-rc-conf --list ipsec
ipsec        2:on       3:on    4:on    5:on


$ sudo sysv-rc-conf xl2tpd on
$ sudo sysv-rc-conf --list xl2tpd
xl2tpd       0:off      1:off   2:on    3:on    4:on    5:on    6:off


後はルータの設定。
UDPの500番、4500番、TCPの50番をRaspberry PIにして完成。

2015年3月8日日曜日

使ってなかったXS35GT V2をなんとかする 2回目

ここしばらくLinux mintで XS35GT V2を使ってましたが、やはりちょっと重い。
ということで、ここのくまさんのを利用してLubuntu非公式日本語版で、なんとかしてみたいです。

USBでくまさんISOのLubuntuのインストールスティックを作ってboot
くまさんのは、初期から日本語なので、楽ですなあ。

ディスクを削除してインストール。
ロケールはTokyo
KeyboardはOADG109を選んでおく。

名前とマシン名ユーザー、パスワードの設定、ログインは必須にしておく。
再起動後、ログイン

今回もドライバのインストールが必要。メニュー、設定、追加のドライバーで、nVidiaのドライバをインストール。再起動後やたら文字が小さくなっているのでいろいろ調べていると、どうもドライバが悪さをするらしいので、なんとかしたいのですが、字が小さすぎて無理なのでとりあえず何とかSSHだけでも入れる。

$ sudo apt-get install openssh-server

SSHから

$ sudo nvidia-xconfig --no-use-edid-dpi

を実行。/etc/X11/xorg.confをいじりたいのでviをインストール

$ sudo apt-get install vim
$ sudo vi /etc/X11/xorg.conf

Section "Screen"
  
  Option         "DPI" " 96 x 96"
EndSection

を追記して、再起動
つづいて、
$ sudo apt-get update
$ sudo apt-get upgrade

あとは、くまさんのおすすめを入れておく。

Ubuntu Tweak (各種設定ツール)
$ sudo add-apt-repository ppa:tualatrix/ppa
$ sudo apt-get update
$ sudo apt-get install ubuntu-tweak

フォント類追加
Ipafont (フォント)
$ sudo apt-get install fonts-ipafont
Vlgothic (フォント)
$ sudo apt-get install fonts-vlgothic

Conky
デスクトップにシステムの情報を表示するツール

NetWorkmanagerが動いていないので

$ sudo vi /etc/NetworkManager/NetworkManager.conf
managed=false

managed=true


$ sudo add-apt-repository ppa:teejee2008/ppa
$ sudo apt-get update
$ sudo apt-get install conky-manager

NASへの連携
$ sudo apt-get install cifs-utils

$ sudo vi /etc/fstab
以下を追記
//192.168.0.15/Media /mnt/ cifs username=hoge,password=fuga,rw,file_mode=0777,dir_mode=0777 0 0

NetWorkmanagerが動いていないので

$ sudo vi /etc/NetworkManager/NetworkManager.conf
dns=dnsmasq
をコメントアウト
#dns=dnsmasq

managed=false

managed=true

後はおなじみXrdp
$ sudo apt-get install git
$ git clone https://github.com/scarygliders/X11RDP-o-Matic.git
$ cd X11RDP-o-Matic
$ sudo ./X11rdp-o-matic.sh --justdoit

で、確認
$ dpkg -l xrdp x11rdp

入っていれば
$ sudo ./RDPsesconfig.sh

で、環境を整備。システムを再起動後リモートデスクトップでアクセスできるかチェック。

って、ここで、なぜか接続されない事態発生。ちーっと調べてみる。