NixOS
VPN to FRITZ!Box from Linux
Requirements
- Packages: vpnc, network-manager-vpnc und network-manager-vpnc-gnome
- MyFRITZ!-address of the FRITZ!Box:
Example: pi80ewgfi72d2os42.myfritz.net - Username of the FRITZ!Box-User:
Example: Max Mustermann - Password of the FRITZ!Box-User:
Example: geheim1234 - Shared Secret of the FRITZ!Box-User:
Example: Zj7hPCouK65IrPU4
Preparations
Setup MyFRITZ!
Register FRITZ!Box at MyFRITZ! for a fixed MyFRITZ!-address. Guide in German
Adjust the IP-Network of the FRITZ!Box
Setup the IP-Address for conecting with the FRITZ!Box:
- Click on "Heimnetz".
- Click on "Heimnetzübersicht".
- Click on "Netzwerkeinstellungen".
- Click on "IPv4-Adressen". If not visible, you have to activate the extended view.
- Enter the IP-Address.
- Save the settings.
Setup the VPN-Connecttion in the FRITZ!Box
Create an own user for every VPN-Connection:
- Click on "System in the FRITZ!Box.
- Click on "FRITZ!Box-Benutzer".
- Edit the prefered user (or create a new one), and setup the vpn connection:
- Click on "Benutzer hinzufügen".
- Enter the username and the password.
- Activate the option "VPN".
- Save the settings.
Setuo the VPN-Connection on your device
- Start Advanced Network Configuration.
- Click on the plus symbol and select ""Cisco-kompatibler VPN-Client (vpnc)" aus.
- Enter the wanted Name.
- Enter the MyFritz!-Address field(pi80ewgfi72d2os42.myfritz.net) in the "Gateway".
- Enter the FritzBox!-Username and -Password and select the option "Passwort nur für diesen Benutzer speichern". aus und tragen Sie dann das Kennwort des FRITZ!Box-Benutzers (geheim1234) ein.
- nter the FritzBox!-Username also in the field "Gruppenname" and select the option "Passwort nur für diesen Benutzer speichern".
- Enter the "Shared Secret" aus und tragen Sie dann das "Shared Secret".
- Click on "Extended".
- Enter "tun0" as "Tunnel-Schnittstellenname".
- Save the settings.
Quelle
Tutorial VPN zur FritzBox einrichten
Install
We follow the UEFI part of the official Installation Guide:
NixOS Installation Guide.
Prepare Disk
Partitioning
Partition the storage using sudo fdisk /dev/sdb
. In the interactive prompt partition the storage those settings:
-
g
(gpt disk label) -
n
-
1
(partition number [1/128]) -
2048
first sector -
+500M
last sector (boot sector size) -
t
-
1
(EFI System) -
n
-
2
- default (fill up partition)
- default (fill up partition)
-
w
(write)
Delete all Files on partitions with:
dd if=/dev/zero of=/dev/sdb1 bs=4096 status=progress
dd if=/dev/zero of=/dev/sdb2 bs=4096 status=progress
Label partitions
Label the partitions using those commands:
sudo mkfs.fat -F 32 /dev/sda1
sudo fatlabel /dev/sda1 NIXBOOT
sudo mkfs.ext4 /dev/sda2 -L NIXROOT
Mount partitions
Mount the boot and root drives so we can access them and install NixOS:
sudo mount /dev/disk/by-label/NIXROOT /mnt
sudo mkdir -p /mnt/boot
sudo mount /dev/disk/by-label/NIXBOOT /mnt/boot
Create swap file
sudo dd if=/dev/zero of=/mnt/.swapfile bs=1024 count=2097152 # 2GB size
sudo chmod 600 /mnt/.swapfile
sudo mkswap /mnt/.swapfile
sudo swapon /mnt/.swapfile
Install Nixos
Create NixOS config
Generate the config using sudo nixos-generate-config --root /mnt
.
Then, edit the config using sudo vim /mnt/etc/nixos/configuration.nix
.
Here are some sections of the configuration you should add:
# Keyboard layout
services.xserver.xkb.layout = "de";
# Add a user!
users.users.elias = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Sudo access
};
# Install an editor to edit the configuration
environment.systemPackages = with pkgs; [ vim ]; # or vim!
To edit the hardware config, use sudo vim /mnt/etc/nixos/hardware-configuration.nix
.
You can then update the file systems to use labels and add the swapfile.
fileSystems."/" =
{ device = "/dev/disk/by-label/NIXROOT";
# ...
};
fileSystems."/boot" =
{ device = "/dev/disk/by-label/NIXBOOT";
# ...
};
swapDevices = [{
device = "/.swapfile";
size = 2048; # 2GB
}];
Install
cd /mnt
sudo nixos-install
Change password with passwd
to a password that works on de
and en
keyboard layout.
Reboot into the installed NixOs.
Add those lines to the configuration.nix
file:
nix.settings.experimental-features = ["nix-command" "flakes" ];
networking.hostName = "eliasDesktop"; #or eiasLaptop for other configs
environment.systemPackages = with pkgs; [
vim
git
];
Rebuild the system with sudo nixos-rebuild switch
and reboot to update the Hostname.
Copy the config repo with git clone https://github.com/4Lost/nixos-config
and move it to /etc/nixos
and rebuild with sudo nixos-rebuild switch
.
Make the directory usable for push and pull:
sudo chown -R elias /etc/nixos