add pppoe
This commit is contained in:
parent
c6e56b1637
commit
c1835d97ee
6 changed files with 164 additions and 0 deletions
47
tests/pppoe/configuration.nix
Normal file
47
tests/pppoe/configuration.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{ config, pkgs, ... } :
|
||||
let
|
||||
inherit (pkgs.liminix.networking) interface address pppoe;
|
||||
inherit (pkgs.liminix.services) oneshot longrun bundle target output;
|
||||
in rec {
|
||||
services.loopback =
|
||||
let iface = interface { type = "loopback"; device = "lo";};
|
||||
in bundle {
|
||||
name = "loopback";
|
||||
contents = [
|
||||
(address iface { family = "inet4"; addr ="127.0.0.1";})
|
||||
(address iface { family = "inet6"; addr ="::1";})
|
||||
];
|
||||
};
|
||||
|
||||
kernel.config = {
|
||||
"PPP" = "y";
|
||||
"PPPOE" = "y";
|
||||
"PPPOL2TP" = "y";
|
||||
};
|
||||
|
||||
services.pppoe =
|
||||
let iface = interface { type = "hardware"; device = "eth0"; };
|
||||
in pppoe iface {};
|
||||
|
||||
services.defaultroute4 =
|
||||
let iface = services.pppoe;
|
||||
in oneshot {
|
||||
name = "defaultroute4";
|
||||
up = ''
|
||||
ip route add default gw $(cat ${output iface "address"})
|
||||
echo "1" > /sys/net/ipv4/$(cat ${output iface "ifname"})
|
||||
'';
|
||||
down = ''
|
||||
ip route del default gw $(cat ${output iface "address"})
|
||||
echo "0" > /sys/net/ipv4/$(cat ${output iface "ifname"})
|
||||
'';
|
||||
dependencies = [iface];
|
||||
};
|
||||
|
||||
services.default = target {
|
||||
name = "default";
|
||||
contents = with services; [ loopback defaultroute4 ];
|
||||
};
|
||||
|
||||
systemPackages = [ pkgs.hello ] ;
|
||||
}
|
20
tests/pppoe/run.sh
Executable file
20
tests/pppoe/run.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
cleanup(){
|
||||
echo "do cleanup";
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR
|
||||
|
||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu.nix>" -A outputs.default $*
|
||||
|
||||
|
||||
if ! ( echo "cont" | socat - unix-connect:../support/ppp-server/qemu-monitor); then
|
||||
echo "need pppoe server running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
../../scripts/run-qemu.sh result/vmlinux result/squashfs
|
Loading…
Add table
Add a link
Reference in a new issue