PPPoE接続の為の主な設定

インストールしてからの主な設定事項です。
セキュリティー的にやっておかなきゃいけないことは別ページで行います。

目次
 ・SELinux無効化
 ・仮想Bridge virbr0の停止
 ・pppoe設定

SELinuxの無効化

サーバーとして使用する端末である場合、SELinuxが有効化されていると思い通りに動かない事(例えば、apacheを起動したのに外部から接続できないとか)も多いので停止&自動起動しないようにしてしまいましょう。
まずはSELinuxが有効になっているか確認。

getenforce
Enforcing

「Enforcing」と返ってきたらSELinuxが有効になっているので恒久的に起動しないように設定します。
/etc/selinux/config ファイルの22行目辺り

を「enforcing」から「disabled」に変更します。

# To revert back to SELinux enabled:
#
#    grubby --update-kernel ALL --remove-args selinux
#
SELINUX=enforcing
# To revert back to SELinux enabled:
#
#    grubby --update-kernel ALL --remove-args selinux
#
SELINUX=disabled

configを変更したらOSを再起動。
改めて確認コマンドを実行して「Disabled」と返ってくればSELinuxは恒久的に起動しないようになった事が確認できた事になります。

getenforce
Disabled

仮想Bridge virbr0の停止

ifconfig コマンドを実行すると環境によって仮想Bridgeのネットワークインターフェイスが自動で設定されていることがあります。
(何をしたら?ハード構成によって?なぜ出てくるのかはわかってません。
が、多分複数のNICが刺さっているとインストール時に設定されるのかも? そこはちゃんと調べず・・・)

ま~私の端末では設定されてしまう。
そして今後仮想スイッチは使う予定がないので停止&自動起動の解除を行います。

ifconfig
********* 仮想部分だけを抜粋 *********
virbr0: flags=4099 mtu 1500
	inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
	ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
	RX packets 0  bytes 0 (0.0 B)
	RX errors 0  dropped 0  overruns 0  frame 0
	TX packets 0  bytes 0 (0.0 B)
	TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


brctl show コマンドを実行してブリッジが認識されているかの確認をします。

brctl show
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.111100fc0000       yes             virbr0-nic


「virbr0」というインターフェイスが表示されるので仮想ブリッジを停止します。

virsh net-destroy default
ネットワーク default は強制停止されました


「強制停止されました」と表示されたので改めてbrctl showコマンドを実行。

brctl show


今度は何も表示されたなくなったので、停止されたことは確認できました。
が、これだけだとOS起動時に自動起動してしまうので自動起動しないように設定変更を行います。
まずは現状確認。

virsh net-list --all
 名前      状態       自動起動     永続
-----------------------------------------------
 default   停止状態   はい (yes)   はい (yes)


virshコマンドを実行した結果、自動起動が「yes」となっているので自動起動設定を解除するコマンドを実行。

virsh net-autostart default --disable
ネットワーク default の自動起動設定が解除されました


「解除されました」と表示されたので改めて確認コマンドを実行。

virsh net-list --all
 名前      状態       自動起動      永続
------------------------------------------------
 default   停止状態   いいえ (no)   はい (yes)

おおっ。自動起動が「no」に変更されました。
これでOS再起動しても仮想ネットワークが起動しなくなりました。
ifconfigコマンドでも表示されなくなりました。

PPPoE設定

サーバー端末はグローバルIPを使用している事が多いはず。
pppoe接続の設定を pppoe-setup コマンドで設定します。
pppoe-setupコマンドは対話形式での設定になるのでコマンドを実行した時のコンソール内容を記載します。
 ・「##」以降は説明のために付け加えたコメントになります。
 ・キーボード入力している行はハイライトしました。

pppoe-setup
======================================================
Welcome to the PPPoE client setup.  First, I will run some checks on
your system to make sure the PPPoE client is installed properly...

LOGIN NAME

Enter your Login Name (default root): xxxxxx@xxxx.com		## プロバイダから展開されている認証に使用するIDを入力

INTERFACE

Enter the Ethernet interface connected to the PPPoE modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where 'X' is a number.
(default eth0): enp1s0				## PPPoE接続に使用するインタフェースを指定

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				## 常時接続にするなら"no"

DNS

Please enter the IP address of your ISP's primary DNS server.
If your ISP claims that 'the server will provide dynamic 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: xxx.xxx.xxx.xxx			## DNSのアドレスをISPが提供するなら"server"

Please enter the IP address of your ISP's secondary DNS server.
If you just press enter, I will assume there is only one DNS server.
Enter the secondary DNS server address here: xxx.xxx.xxx.xxx		## ISPから固定で提供されているので記入する。
						## "server"にした場合は、adsl-startスクリプトとadsl-stopスクリプトが/etc/resolv.confを書き換える

PASSWORD

Please enter your Password:			## 認証に使用するパスワードを入力(キーボード入力しても何の反応もない)
Please re-enter your Password:		## 認証に使用するパスワードを再度入力(キーボード入力しても何の反応もない)

USERCTRL

Please enter 'yes' (three letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes): no		## 一般ユーザにPPPoEの接続/切断を許可しないので"no"を指定

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
## "0" : ファイアウォールを使用しない。
##       別途iptablesなどで防衛すること。
## "1" : PPPoE接続に使用するインタフェースからの特権ポート(0~1023)に対するインバウンドパケットをドロップする。
##       ルールは/etc/ppp/firewall-standaloneファイルにiptablesコマンドで記述されている。
## "2" : PPPoEルータのような動作をする。
##       PPPoE接続に使用するインタフェースからの特権ポート(0~1023)に対するインバウンドパケットをドロップする。
##       ルールは/etc/ppp/firewall-masqファイルにiptablesコマンドで記述されている。

Choose a type of firewall (0-2): 0						## 使用するファイアウォールの種類を指定する
														## サーバとして使用する端末なので「0」を指定。

Start this connection at boot time

Do you want to start this connection at boot time?
Please enter no or yes (default no):yes			## PC起動時にPPPoE接続を開始するなら"yes"

## 最後に入力内容を確認します。
** Summary of what you entered **

Ethernet Interface: enp1s0
User name:          xxxxxx@xxxx.com
Activate-on-demand: No
Primary DNS:        xxx.xxx.xxx.xxx
Secondary DNS:      xxx.xxx.xxx.xxx
Firewalling:        NONE
User Control:       no
Accept these settings and adjust configuration files (y/n)? y		## 確認してOKであれば"y"
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
  (But first backing it up to /etc/ppp/chap-secrets.bak)
  (But first backing it up to /etc/ppp/pap-secrets.bak)

Congratulations, it should be all set up!

Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
to bring it down.
Type '/sbin/pppoe-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
to see the link status.

これでpppoe接続インターフェイスの「ppp0」が生成されたので接続コマンドを実行します。

pppoe-start

これでグローバルIPを持ったサーバの完成です。

しかし・・・
このコマンドになる前「adsl-setup」コマンドの頃はOS起動したら自動的に接続してくれてたのに、「pppoe-setup」コマンドに変更されてから自動接続してくれなくなってしまった。
なぜ自動接続してくれなくなってしまったのかわからず・・・(ログも確認してないんだけど・・・)

自動でpppoe接続してくれなくなってしまったので、応急的にcronを使って2分おきに接続確認をして切断されたらpppoe-startコマンドを実行する為の設定はこちら。
これであれば、もし何かの影響でpppoe接続が切断されてしまった場合も2分おきに接続チェックして接続するのでこのままにしています。