LoginSignup
3
1

More than 5 years have passed since last update.

Amazon LinuxでPPP接続時にルーティングを追加する

Posted at

条件

  • L2TP/IPsecでVPNに接続している
  • PPP(VPN)接続時に自動的にルーティングを追加したい
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.5  netmask 255.255.255.0  broadcast 192.168.1.255


lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0


ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1400
        inet 192.168.30.201  netmask 255.255.255.255  destination 1.0.0.1
        ppp  txqueuelen 3  (Point-to-Point Protocol)

PPP接続時の起動スクリプトを作成する

/etc/ppp/ip-upは編集せずに新規でip-up.localを作成する

$ sudo vi /etc/ppp/ip-up.local

ルーティングを追加するスクリプトを記述する

ip-up.local
#!/bin/sh
ip route add [宛先のIPアドレス] via 192.168.30.201 dev ppp0
exit 0

実行権限を追加する

$ sudo chmod 755 /etc/ppp/ip-up.local

PPPを再接続してルーティングが追加されていることを確認する

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
1.0.0.1         0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
[宛先のIPアドレス]   192.168.30.201  255.255.255.255 UGH   0      0        0 ppp0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1