【2022年版】Ubuntu 20.04.4 LTS で PPPoE接続する方法

# はじめに

Ubuntu 20.04.4 LTS で PPPoE接続をします。
PPPoE接続に必要な ```ユーザ名``` と ```パスワード``` を準備します。
外部から接続可能になると思いますので、```ufw``` で Firewall の設定はしておきましょう。

* 20225ポートのみを開けたい場合

```terminal
~$ sudo ufw enable
~$ sudo ufw allow 20225
~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
20225                      ALLOW IN    Anywhere                  
20225 (v6)                 ALLOW IN    Anywhere (v6)             
```

# 環境

```terminal
~$ uname -a
Linux ubuntu 5.4.0-121-generic #137-Ubuntu SMP Wed Jun 15 13:33:07 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
```

# インストール

```terminal
~$ sudo apt install pppoe pppoeconf
```

# 設定

* ダイアログ形式で設定を行う。
* ユーザ名とパスワード以外は全て YES でも良い。
* DNSを既存のものを使いたいなら、 ```USE PEER DNS``` を No にする
* 起動時に自動接続されるので、嫌なら、```Your PPPD is configured now. Would you like to start the connection at boot time?``` を No にする。
* ダイアログに multi-modem などが表示されてうまくいかないときは、PPPoE接続先のみにネットワークケーブルを絞る。

```terminal
~$ sudo pppoeconf
                 ┌───────────────────┤ SCANNING DEVICE ├────────────────────┐                 
                 │ Looking for PPPoE Access Concentrator on enp1s0...       │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                            88%                           │                 
                 │                                                          │                 
                 └──────────────────────────────────────────────────────────┘                 
                                                                                              

     ┌─────────────────────────┤ OKAY TO MODIFY ├─────────────────────────┐     
     │                                                                    │     
     │ If you continue with this program, these configuration files will  │     
     │ be modified : /etc/ppp/peers/dsl-provider /etc/network/interfaces  │     
     │ and /etc/ppp/*-secrets. Please make sure that you have a backup    │     
     │ copy before saying Yes.                                            │     
     │                                                                    │     
     │ Continue with configuration?                                       │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                                                                    │     
     │                  <Yes>                     <No>                    │
     └────────────────────────────────────────────────────────────────────┘     

            ┌────────────────────────┤ POPULAR OPTIONS ├─────────────────────────┐            
            │                                                                    │            
            │ Most people using popular dialup providers prefer the options      │            
            │ 'noauth' and 'defaultroute' in their configuration and remove the  │            
            │ 'nodetach' option. Should I check your configuration file and      │            
            │ change these settings where neccessary?                            │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                                                                    │            
            │                  <Yes>                     <No>                    │            
            │                                                                    │            
            └────────────────────────────────────────────────────────────────────┘            
                                                                                                                                                                              
          ┌────────────────────┤ ENTER USERNAME ├────────────────────┐          
          │ Please enter the username which you usually need for the │          
          │ PPP login to your provider in the input box below. If    │          
          │ you wish to see the help screen, delete the username and │          
          │ press OK.                                                │          
          │                                                          │          
          │ username________________________________________________ │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                          <Ok>                            │          
          │                                                          │          
          └──────────────────────────────────────────────────────────┘          
                                                                                
                 ┌────────────────────┤ ENTER PASSWORD ├────────────────────┐                 
                 │ Please enter the password which you usually need for the │                 
                 │ PPP login to your provider in the input box below.       │                 
                 │                                                          │                 
                 │ NOTE: you can see the password in plain text while       │                 
                 │ typing.                                                  │                 
                 │                                                          │                 
                 │ ________________________________________________________ │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                          <Ok>                            │                 
                 │                                                          │                 
                 └──────────────────────────────────────────────────────────┘                 

                                                                                              
                 ┌─────────────────────┤ USE PEER DNS ├─────────────────────┐                 
                 │                                                          │                 
                 │ You need at least one DNS IP address to resolve the      │                 
                 │ normal host names. Normally your provider sends you      │                 
                 │ addresses of useable servers when the connection is      │                 
                 │ established. Would you like to add these addresses       │                 
                 │ automatically to the list of nameservers in your local   │                 
                 │ /etc/resolv.conf file? (recommended)                     │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │                                                          │                 
                 │               <Yes>                  <No>                │                 
                 │                                                          │                 
                 └──────────────────────────────────────────────────────────┘                 
                                                                                                                                                                                            
     ┌──────────────────────┤ LIMITED MSS PROBLEM ├───────────────────────┐     
     │                                                                    │     
     │ Many providers have routers that do not support TCP packets with a │     
     │ MSS higher than 1460. Usually, outgoing packets have this MSS when │     
     │ they go through one real Ethernet link with the default MTU size   │     
     │ (1500). Unfortunately, if you are forwarding packets from other    │     
     │ hosts (i.e. doing masquerading) the MSS may be increased depending │     
     │ on the packet size and the route to the client hosts, so your      │     
     │ client machines won't be able to connect to some sites. There is a │     
     │ solution: the maximum MSS can be limited by pppoe. You can find    │     
     │ more details about this issue in the pppoe documentation.          │     
     │                                                                    │     
     │ Should pppoe clamp MSS at 1452 bytes?                              │     
     │                                                                    │     
     │ If unsure, say yes.                                                │     
     │                                                                    │     
     │ (If you still get problems described above, try setting to 1412 in │     
     │ the dsl-provider file.)                                            │     
     │                                                                    │     
     │                  <Yes>                     <No>                    │     
     │                                                                    │     
     └────────────────────────────────────────────────────────────────────┘     

                                                                                
          ┌─────────────────────────┤ DONE ├─────────────────────────┐          
          │                                                          │          
          │ Your PPPD is configured now. Would you like to start the │          
          │ connection at boot time?                                 │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │               <Yes>                  <No>                │          
          │                                                          │          
          └──────────────────────────────────────────────────────────┘          
                                                                                

          ┌────────────────┤ ESTABLISH A CONNECTION ├────────────────┐          
          │                                                          │          
          │ Now, you can make a DSL connection with "pon             │          
          │ dsl-provider" and terminate it with "poff". Would you    │          
          │ like to start the connection now?                        │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │                                                          │          
          │               <Yes>                  <No>                │          
          │                                                          │          
          └──────────────────────────────────────────────────────────┘          
                                                                                

                                                                                
          ┌─────────────────┤ CONNECTION INITIATED ├─────────────────┐          
          │                                                          │          
          │ The DSL connection has been triggered. You can use the   │          
          │ "plog" command to see the status or "ip addr show ppp0"  │          
          │ for general interface info.                              │          
          │                                                          │          
          │                                                          │          
          │                          <Ok>                            │          
          │                                                          │          
          └──────────────────────────────────────────────────────────┘   
```

# 接続確認

設定直後から接続できている。


```terminal
17: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1454 qdisc fq_codel state UNKNOWN group default qlen 3
    link/ppp 
    inet XXX.XXX.XXX.XXX peer XXX.XXX.XXX.XXX/32 scope global ppp0
       valid_lft forever preferred_lft forever
```

# その他

* PPPoEの設定ファイル

  ```/etc/ppp/peers/dsl-provider```

* PPPoEの手動切断

```terminal
~$ poff dsl-provider
```

* PPPoEの手動接続

```terminal
~$ pon dsl-provider
```

# おわりに

  かんたんでしたね