Linux で PPPoE
環境はCentOS5
(CentOS 4.2でも同様の作業で動作済)
カーネルモードPPPoEをやりたいので、
samba.org より CVS で最新のpppモジュールのソースを取得します。
cd /usr/local/src cvs -d :pserver:cvs@pserver.samba.org:/cvsroot login cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co ppp
コンパイルし、インストールします
cd ppp
./configure
make
make install
PPPoEクライアントプログラム rp-pppoe をインストールします
http://www.roaringpenguin.com/products/pppoe
から取得し、展開します
wget http://www.roaringpenguin.com/files/download/rp-pppoe-3.8.tar.gz tar -zxvf rp-pppoe-3.8.tar.gz cd rp-pppoe-3.8/src ./configure --enable-plugin=/path/to/src/of/ppp --disable-debugging
ここではまったのがpppのバージョンがある一定以上(未調査)だと
makeで
make: *** [plugin/plugin.o] エラー 1
とでてうまくいかない
これを解決するには
./configure してできたMakefileを
vi Makefile
として
-CFLAGS= -g -O2 -Wall -Wstrict-prototypes -ansi $(LIC_INCDIR) $(DEFINES) $(LIC_DEFINE) $(PATHS) -Ilibevent +CFLAGS= -g -O2 -Wall -Wstrict-prototypes $(LIC_INCDIR) $(DEFINES) $(LIC_DEFINE) $(PATHS) -Ilibevent
として
make make install
これでrp-pppoeのインストールは完了
PPPoEアカウントの設定をします
pppoe-setup Welcome to the Roaring Penguin PPPoE client setup. First, I will run some checks on your system to make sure the PPPoE client is installed properly... Looks good! Now, please enter some information: USER NAME >>> Enter your PPPoE user name (default hoge@localhost): プロバイダから指定されたログインユーザ名を入力し Enterキーを押します。 INTERFACE >>> Enter the Ethernet interface connected to the DSL modem For Solaris, this is likely to be something like /dev/hme0. For Linux, it will be ethn, where 'n' is a number. (default eth0): デバイス名を入力し Enterキーを押します。 (default eth0) と書かれているので、何も入力せずに Enterキーを押すと eth0 を入力したのと同じことになります Do you want the link to come up on demand, or stay up continuously? If you want it to come up on demand, enter the idle time in seconds after which the link should be dropped. If you want the link to stay up permanently, enter 'no' (two letters, lower-case.) NOTE: Demand-activated links do not interact well with dynamic IP addresses. You may have some problems with demand-activated links. >>> Enter the demand value (default no): オンデマンド接続を利用するかを、切断までのアイドル時間(秒) か no(利用しない) で答えます 何も入力せずに Enterキーを押すと no(利用しない) になります DNS Please enter the IP address of your ISP's primary DNS server. If your ISP claims that 'the server will provide DNS addresses', enter 'server' (all lower-case) here. If you just press enter, I will assume you know what you are doing and not modify your DNS setup. >>> Enter the DNS information here: プロバイダから DNS サーバのIP アドレスを指定されている場合は、プライマリDNS のIPアドレスを入力 自動取得の場合 server を入力 DNSの IPアドレスを入力した場合セカンダリDNS のIPアドレスを聞かれます Please enter the IP address of your ISP's secondary DNS server. If you just presss enter, I will assume there is only one DNS server. >>> Enter the secondary DNS server address here: セカンダリDNS のIPアドレスを入力 セカンダリDNS の指定がなければ空で PASSWORD >>> Please enter your PPPoE password: プロバイダから指定されたPPPoE接続用のパスワードを入力 >>> Please re-enter your PPPoE password: 確認のため、もう一度パスワードを入力 FIREWALLING Please choose the firewall rules to use. Note that these rules are very basic. You are strongly encouraged to use a more sophisticated firewall setup; however, these will provide basic security. If you are running any servers on your machine, you must choose 'NONE' and set up firewalling yourself. Otherwise, the firewall rules will deny access to all standard servers like Web, e-mail, ftp, etc. If you are using SSH, the rules will block outgoing SSH connections which allocate a privileged source port. The firewall choices are: 0 - NONE: This script will not set any firewall rules. You are responsible for ensuring the security of your machine. You are STRONGLY recommended to use some kind of firewall rules. 1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation 2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway for a LAN >>> Choose a type of firewall (0-2): ファイアウォールについての設定を行います。0 1 2 のどれかを選択 0 - 設定しない 1 - スタンドアローン: PPPoE 接続を利用するのがこのPCだけでのとき 2 - マスカレード: この PC を ルータ として利用するとき ※0を設定して独自にiptablesでルーティングしたほうがわかりやすくていいよ ** Summary of what you entered ** Ethernet Interface: eth0 User name: username@domainname Activate-on-demand: No DNS: Do not adjust Firewalling: NONE >>> Accept these settings and adjust configuration files (y/n)? 設定がこれでよければ y でファイルに保存 nを選択すると最初からやり直しになります Adjusting /etc/ppp/pppoe.conf Adjusting /etc/ppp/pap-secrets and /etc/ppp/chap-secrets (But first backing it up to /etc/ppp/pap-secrets-bak) (But first backing it up to /etc/ppp/chap-secrets-bak) Congratulations, it should be all set up! Type 'pppoe-start' to bring up your PPPoE link and 'pppoe-stop' to bring it down. Type 'pppoe-status' to see the link status.
設定内容が、
/etc/ppp/pppoe.conf /etc/ppp/pap-secrets /etc/ppp/chap-secrets
に書き込まれました。
バックアップファイルが
/etc/ppp/pap-secrets-bak /etc/ppp/chap-secrets-bak
に作成されています
これで pppoe-setup は完了
使用されるNICの設定をします
vi /etc/sysconfig/network-scripts/ifcfg-eth0
eth0 は 認識されるだけの状態にしておきます。
DEVICE=eth0 BOOTPROTO=none ONBOOT=no HWADDR=**.**.**.**.**.**
ONBOOT は pppoe-start → pppoe-connect にて起動されるので no のほうが望ましいと思う
これでPPPoE接続するための設定は完了
pppoe-start
とすると、接続が開始されます
起動時に動かしたい場合は、
rp-pppoe の make install 時に /etc/rc.d/init.d/pppoe が作成されているので
chkconfig --add /etc/rc.d/init.d/pppoe
で次回から自動起動されます
カーネルモードとユーザモード
ユーザモードでPPPoEを動かすと
pppd(kernel level) → rp-pppoe(user level) → NIC(kenerl level)
となるのでコンテキストスイッチが多発する。
そのため転送速度は低下し、CPUもかなり必要と、メリットが無い
カーネルモードで動かすと
pppd(kernel level) が rp-pppoe(モジュール使用) → NIC(kenerl level)
となりコンテキストスイッチの発生が少ない。
このためユーザモードと比べると
CPU負荷で1/2〜1/4程度、転送性能だと133%〜300%と
劇的な性能向上を見込める。
設定は簡単で
vi /etc/ppp/pppoe.conf
で
-LINUX_PLUGIN= +LINUX_PLUGIN=/etc/ppp/plugins/rp-pppoe.so
として
pppoe を再起動(service pppe restart とか ppppe-stop → pppoe-start とか)してあげる
ただし、rp-pppoe の./configure をするときに、
--enable-plugin=/path/to/src/of/ppp として
rp-pppoe.so モジュールを ppp のソースを参照して作成するように
教えてあげないとカーネルモードは使えない
また、
ユーザモードだと rp-pppoe が
/etc/ppp/pppoe.conf で
CLAMPMSS=1412
としてMSSのサイズが1412byteに固定されているため
Path MTU Discovery Black Hole が発生することは無いが、
カーネルモードで動作させた場合この設定は無視されるため、
iptables で
/sbin/iptables -A FORWARD -o ppp0 -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
とするとMTUをPMTU -40 にしてくれるので、
これを使うと解決するナリ