1let
2 chap-secrets = {
3 text = ''"flynn" * "reindeerflotilla" *'';
4 mode = "0640";
5 };
6in
7{ pkgs, ... }:
8{
9 name = "pppd";
10
11 meta = with pkgs.lib.maintainers; {
12 maintainers = [ stv0g ];
13 };
14
15 nodes = {
16 server =
17 { config, pkgs, ... }:
18 {
19 config = {
20 # Run a PPPoE access concentrator server. It will spawn an
21 # appropriate PPP server process when a PPPoE client sets up a
22 # PPPoE session.
23 systemd.services.pppoe-server = {
24 restartTriggers = [
25 config.environment.etc."ppp/pppoe-server-options".source
26 config.environment.etc."ppp/chap-secrets".source
27 ];
28 after = [ "network.target" ];
29 serviceConfig = {
30 ExecStart = "${pkgs.rpPPPoE}/sbin/pppoe-server -F -O /etc/ppp/pppoe-server-options -q ${pkgs.ppp}/sbin/pppd -I eth1 -L 192.0.2.1 -R 192.0.2.2";
31 };
32 wantedBy = [ "multi-user.target" ];
33 };
34 environment.etc = {
35 "ppp/pppoe-server-options".text = ''
36 lcp-echo-interval 10
37 lcp-echo-failure 2
38 plugin pppoe.so
39 require-chap
40 nobsdcomp
41 noccp
42 novj
43 '';
44 "ppp/chap-secrets" = chap-secrets;
45 };
46 };
47 };
48 client =
49 { config, pkgs, ... }:
50 {
51 services.pppd = {
52 enable = true;
53 peers.test = {
54 config = ''
55 plugin pppoe.so eth1
56 name "flynn"
57 noipdefault
58 persist
59 noauth
60 debug
61 '';
62 };
63 };
64 environment.etc."ppp/chap-secrets" = chap-secrets;
65 };
66 };
67
68 testScript = ''
69 start_all()
70 client.wait_until_succeeds("ping -c1 -W1 192.0.2.1")
71 server.wait_until_succeeds("ping -c1 -W1 192.0.2.2")
72 '';
73}