OpenVPN: Difference between revisions
Add network-manager integration |
m →VPN Client: $ -> # to indicate root; replace backticks with <code> |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 6: | Line 6: | ||
... | ... | ||
services.openvpn.servers = { | services.openvpn.servers = { | ||
officeVPN = { config = | officeVPN = { config = "config /root/nixos/openvpn/officeVPN.conf"; }; | ||
homeVPN = { config = | homeVPN = { config = "config /root/nixos/openvpn/homeVPN.conf"; }; | ||
serverVPN = { config = | serverVPN = { config = "config /root/nixos/openvpn/serverVPN.conf"; }; | ||
}; | }; | ||
... | ... | ||
| Line 18: | Line 18: | ||
Ensure you use absolute paths for any files such as certificates and keys referenced from the configuration files. | Ensure you use absolute paths for any files such as certificates and keys referenced from the configuration files. | ||
Use <em>systemctl</em> to start/stop VPN service. Each generated service will have a prefix | Use <em>systemctl</em> to start/stop VPN service. Each generated service will have a prefix <code>openvpn-</code>: | ||
<syntaxHighlight> | <syntaxHighlight lang=console> | ||
systemctl start openvpn-officeVPN.service | # systemctl start openvpn-officeVPN.service | ||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 30: | Line 30: | ||
services.openvpn.servers = { | services.openvpn.servers = { | ||
officeVPN = { | officeVPN = { | ||
config = | config = "config /root/nixos/openvpn/officeVPN.conf"; | ||
updateResolvConf = true; | updateResolvConf = true; | ||
}; | }; | ||
| Line 67: | Line 67: | ||
device = "//10.8.0.x/Share"; | device = "//10.8.0.x/Share"; | ||
fsType = "cifs"; | fsType = "cifs"; | ||
options = [ "noauto" "user" "uid=1000" "gid=100" "username=xxx" "password=xxx" "iocharset=utf8" | options = [ | ||
"x-systemd.requires=openvpn-officeVPN.service" ]; | "noauto" | ||
"user" | |||
"uid=1000" | |||
"gid=100" | |||
"username=xxx" | |||
"password=xxx" | |||
"iocharset=utf8" | |||
"x-systemd.requires=openvpn-officeVPN.service" | |||
]; | |||
}; | }; | ||
fileSystems."/mnt/home" = { | fileSystems."/mnt/home" = { | ||
device = "//10.9.0.x/Share"; | device = "//10.9.0.x/Share"; | ||
fsType = "cifs"; | fsType = "cifs"; | ||
options = [ "noauto" "user" "uid=1000" "gid=100" "username=xxx" "password=xxx" "iocharset=utf8" | options = [ | ||
"x-systemd.requires=openvpn-homeVPN.service" ]; | "noauto" | ||
"user" | |||
"uid=1000" | |||
"gid=100" | |||
"username=xxx" | |||
"password=xxx" | |||
"iocharset=utf8" | |||
"x-systemd.requires=openvpn-homeVPN.service" | |||
]; | |||
}; | }; | ||
... | ... | ||
| Line 104: | Line 120: | ||
vpn-dev = "tun0"; | vpn-dev = "tun0"; | ||
port = 1194; | port = 1194; | ||
in { | in | ||
{ | |||
# sudo systemctl start nat | # sudo systemctl start nat | ||
networking.nat = { | networking.nat = { | ||
enable = true; | enable = true; | ||
externalInterface = <your-server-out-if>; | externalInterface = <your-server-out-if>; | ||
internalInterfaces | internalInterfaces = [ vpn-dev ]; | ||
}; | }; | ||
networking.firewall.trustedInterfaces = [ vpn-dev ]; | networking.firewall.trustedInterfaces = [ vpn-dev ]; | ||