Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
add dhcp client
Browse files Browse the repository at this point in the history
  • Loading branch information
telent committed May 8, 2018
1 parent 2b6adb9 commit da13ade
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion backuphost.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,36 @@ in rec {
]); in
writeScriptBin "switchconfig.sh" script;

dhcpscript = writeScriptBin "dhcpscript" ''
#!/bin/sh
dev=eth0.2
deconfig(){
ip addr flush dev $dev
}
bound(){
ip addr replace $ip/$mask dev $dev ;
ip route add 0.0.0.0/0 via $router;
}
case $1 in
deconfig)
deconfig
;;
bound|renew)
bound
;;
*)
echo unrecognised command $1
;;
esac
'';

rootfs = nixwrt.rootfsImage {
inherit (nixwrt) monit busybox;
iproute = iproute_;
configuration = {
interfaces = {
"eth0.2" = {
ipv4Address = "192.168.0.251/24";
# ipv4Address = "192.168.0.251/24";
type = "vlan"; id = 2; dev = "eth0"; depends = [];
};
"eth0" = { } ;
Expand Down Expand Up @@ -88,6 +111,10 @@ in rec {
depends = [ "eth0.2"];
hostKey = ./ssh_host_key;
};
udhcpc = {
start = "${nixwrt.busybox}/bin/udhcpc -p /run/udhcpc.pid -s '${dhcpscript}/bin/dhcpscript'";
depends = [ "eth0.2"];
};
syslogd = { start = "/bin/syslogd -R 192.168.0.2";
depends = ["eth0.2"]; };
ntpd = { start = "/bin/ntpd -p pool.ntp.org" ;
Expand Down

0 comments on commit da13ade

Please sign in to comment.