mirror of
https://github.com/QubesOS/qubes-doc.git
synced 2024-10-01 01:25:40 -04:00
fix, not tied to AppVMs but VMs generally
This commit is contained in:
parent
2eaf76cf43
commit
bdb036fdbc
@ -14,7 +14,7 @@ Understanding Qubes networking and firewall
|
||||
Understanding firewalling in Qubes
|
||||
----------------------------------
|
||||
|
||||
Every AppVM in Qubes is connected to the network via a FirewallVM, which is used to enforce network-level policies. By default there is one default Firewall VM, but the user is free to create more, if needed.
|
||||
Every VM in Qubes is connected to the network via a FirewallVM, which is used to enforce network-level policies. By default there is one default Firewall VM, but the user is free to create more, if needed.
|
||||
|
||||
For more information, see the following:
|
||||
|
||||
@ -32,38 +32,38 @@ Note that if you specify a rule by DNS name it will be resolved to IP(s) *at the
|
||||
|
||||
Alternatively, one can use the `qvm-firewall` command from Dom0 to edit the firewall rules by hand:
|
||||
|
||||
Reconnecting AppVMs after a NetVM reboot
|
||||
Reconnecting VMs after a NetVM reboot
|
||||
----------------------------------------
|
||||
|
||||
Normally Qubes doesn't let the user to stop a NetVM if there are other AppVMs running which use it as their own NetVM. But in case the NetVM stops for whatever reason (e.g. it crashes, or the user forces its shutdown via qvm-kill via terminal in the netvm), then there is an easy way to restore the connection to the netvm by issuing:
|
||||
Normally Qubes doesn't let the user to stop a NetVM if there are other VMs running which use it as their own NetVM. But in case the NetVM stops for whatever reason (e.g. it crashes, or the user forces its shutdown via qvm-kill via terminal in the netvm), then there is an easy way to restore the connection to the netvm by issuing:
|
||||
|
||||
~~~
|
||||
qvm-prefs <appvm> -s netvm <netvm>
|
||||
qvm-prefs <vm> -s netvm <netvm>
|
||||
~~~
|
||||
|
||||
Normally AppVMs do not connect directly to the actual NetVM which has networking devices, but rather to the default FirewallVM first, and in most cases it would be the NetVM that would crash, e.g. in response to S3 sleep/restore or other issues with WiFi drivers. In that case it is necessary to just issue the above command once, for the FirewallVM (this assumes default VM-nameing used by the default Qubes installation):
|
||||
Normally VMs do not connect directly to the actual NetVM which has networking devices, but rather to the default FirewallVM first, and in most cases it would be the NetVM that would crash, e.g. in response to S3 sleep/restore or other issues with WiFi drivers. In that case it is necessary to just issue the above command once, for the FirewallVM (this assumes default VM-nameing used by the default Qubes installation):
|
||||
|
||||
~~~
|
||||
qvm-prefs firewallvm -s netvm netvm
|
||||
~~~
|
||||
|
||||
Enabling networking between two AppVMs
|
||||
Enabling networking between two VMs
|
||||
--------------------------------------
|
||||
|
||||
Normally any networking traffic between VMs is prohibited for security reasons. However, in special situations, one might one to selectively allow specific AppVMs to be able to establish networking connectivity between each other. For example, this might come useful in some development work, when one wants to test networking code, or to allow file exchange between HVM domains (which do not have Qubes tools installed) via SMB/scp/NFS protocols.
|
||||
Normally any networking traffic between VMs is prohibited for security reasons. However, in special situations, one might one to selectively allow specific VMs to be able to establish networking connectivity between each other. For example, this might come useful in some development work, when one wants to test networking code, or to allow file exchange between HVM domains (which do not have Qubes tools installed) via SMB/scp/NFS protocols.
|
||||
|
||||
In order to allow networking between AppVM A and B follow those steps:
|
||||
In order to allow networking between VM A and B follow those steps:
|
||||
|
||||
- Make sure both A and B are connected to the same firewall vm (by default all AppVMs use the same firewall VM).
|
||||
- Note the Qubes IP addresses assigned to both AppVMs. This can be done using the `qvm-ls -n` command, or via the Qubes Manager preferences pane for each AppVM.
|
||||
- Start both AppVMs, and also open a terminal in the firewall VM
|
||||
- Make sure both A and B are connected to the same firewall vm (by default all VMs use the same firewall VM).
|
||||
- Note the Qubes IP addresses assigned to both VMs. This can be done using the `qvm-ls -n` command, or via the Qubes Manager preferences pane for each VM.
|
||||
- Start both VMs, and also open a terminal in the firewall VM
|
||||
- In the firewall VM's terminal enter the following iptables rule:
|
||||
|
||||
~~~
|
||||
sudo iptables -I FORWARD 2 -s <IP address of A> -d <IP address of B> -j ACCEPT
|
||||
~~~
|
||||
|
||||
- Now you should be able to reach the AppVM B from A -- test it using e.g. ping issues from AppVM A. Note however, that this doesn't allow you to reach A from B -- for this you would need another rule, with A and B addresses swapped.
|
||||
- Now you should be able to reach the VM B from A -- test it using e.g. ping issues from VM A. Note however, that this doesn't allow you to reach A from B -- for this you would need another rule, with A and B addresses swapped.
|
||||
- If everything works as expected, then the above iptables rule(s) should be written into firewall VM's `qubes_firewall_user_script` script which is run on every firewall update. This is necessary, because Qubes orders every firewall VM to update all the rules whenever new VM is started in the system. If we didn't enter our rules into this "hook" script, then shortly our custom rules would disappear and inter-VM networking would stop working. Here's an example how to update the script (note that, by default, there is no script file present, so we likely will be creating it, unless we had some other custom rules defines earlier in this firewallvm):
|
||||
|
||||
~~~
|
||||
@ -72,14 +72,14 @@ In order to allow networking between AppVM A and B follow those steps:
|
||||
[root@firewallvm user]# chmod +x /rw/config/qubes_firewall_user_script
|
||||
~~~
|
||||
|
||||
Port forwarding to an AppVM from the outside world
|
||||
Port forwarding to an VM from the outside world
|
||||
--------------------------------------------------
|
||||
|
||||
In order to allow a service present in an AppVM to be exposed to the outside world in the default setup (where the AppVM has the FirewallVM as network VM, which in turn has the NetVM as network VM) the following needs to be done:
|
||||
In order to allow a service present in an VM to be exposed to the outside world in the default setup (where the VM has the FirewallVM as network VM, which in turn has the NetVM as network VM) the following needs to be done:
|
||||
|
||||
- In the NetVM, allow packets to be routed from the outside world to the FirewallVM and allow packets through the NetVM firewall
|
||||
- In the FirewallVM, allow packets to be routed from the NetVM to the AppVM and allow packets through the FirewallVM firewall
|
||||
- In the AppVM, allow packets into the AppVM firewall to reach the service
|
||||
- In the FirewallVM, allow packets to be routed from the NetVM to the VM and allow packets through the FirewallVM firewall
|
||||
- In the VM, allow packets into the VM firewall to reach the service
|
||||
|
||||
As an example we can take the use case of a web server listenning on port 443 that we want to expose on our physical interface eth0, but only to our local network 192.168.0.0/24.
|
||||
|
||||
@ -135,13 +135,13 @@ Make this file executable:
|
||||
sudo chmod +x /rw/config/rc.local
|
||||
~~~
|
||||
|
||||
**2. Allow packets to be routed from the firewallVM to the appVM**
|
||||
**2. Allow packets to be routed from the firewallVM to the VM**
|
||||
|
||||
In System Tools (Dom0) / Terminal, take note of the appVM (on which the service is exposed) IPAddress using the command ` qvm-ls -n `
|
||||
In System Tools (Dom0) / Terminal, take note of the VM (on which the service is exposed) IPAddress using the command ` qvm-ls -n `
|
||||
|
||||
In FirewallVM Terminal, take note of the IPAddress for interface eth0 using the command ` ifconfig | grep -i cast `
|
||||
|
||||
Still in FirewallVM terminal, code the appropriate natting firewall rule to intercept traffic on the inbound interface for the service and nat the destination IP address to the one of the AppVM for the traffic to be routed there:
|
||||
Still in FirewallVM terminal, code the appropriate natting firewall rule to intercept traffic on the inbound interface for the service and nat the destination IP address to the one of the VM for the traffic to be routed there:
|
||||
|
||||
~~~
|
||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -d 10.137.1.x -j DNAT --to-destination 10.137.2.y
|
||||
@ -175,7 +175,7 @@ And again make this file executable:
|
||||
sudo chmod +x /rw/config/qubes_firewall_user_script
|
||||
~~~
|
||||
|
||||
**3. Allow packets into the AppVM to reach the service**
|
||||
**3. Allow packets into the VM to reach the service**
|
||||
|
||||
Here no routing is required, only filtering. Proceed in the same way as above but store the filtering rule in the `/rw/config/rc.local` script.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user