1 |
Am 28.01.2013 22:49, schrieb Stefan G. Weichinger: |
2 |
|
3 |
>>> ps: my bigger hurdle will be the bridging-setup for running |
4 |
>>> KVM-virtualization. This was one of the reasons to go back to openrc |
5 |
>>> back then. |
6 |
>> |
7 |
>> I have no experience with that, but if it works in OpenRC it should |
8 |
>> work in systemd. Probably better, even. |
9 |
> |
10 |
> I don't think it won't work, I just wonder how to do it in the right and |
11 |
> most efficient way. I will think about that later/tomorrow maybe, |
12 |
> already late here ... |
13 |
|
14 |
I have a *draft* here for bridge.service ... I used the init.d-script |
15 |
from here as a template: |
16 |
|
17 |
http://en.gentoo-wiki.com/wiki/KVM#Script_to_ease_the_configuration |
18 |
|
19 |
(I used a variation of that as /etc/init.d/kvm for long now) |
20 |
|
21 |
My service-file reads variables from a separated configfile: |
22 |
|
23 |
# cat /etc/conf.d/network_systemd |
24 |
interface=eth0 |
25 |
address=172.32.99.12 |
26 |
netmask=255.255.255.0 |
27 |
broadcast=172.32.99.255 |
28 |
gateway=172.32.99.250 |
29 |
bridge_name=br0 |
30 |
tap_name=qtap0 |
31 |
user=sgw |
32 |
|
33 |
|
34 |
and it currently looks like this: |
35 |
|
36 |
# cat /etc/systemd/system/bridge.service |
37 |
[Unit] |
38 |
Description=network bridge for KVM |
39 |
After=network.target |
40 |
|
41 |
[Service] |
42 |
Type=oneshot |
43 |
RemainAfterExit=yes |
44 |
|
45 |
EnvironmentFile=/etc/conf.d/network_systemd |
46 |
|
47 |
ExecStart=/sbin/brctl addbr ${bridge_name} |
48 |
ExecStart=/usr/bin/tunctl -b -u ${user} -t ${tap_name} |
49 |
ExecStart=/bin/ifconfig ${bridge_name} ${address} netmask ${netmask} up |
50 |
ExecStart=/bin/ifconfig ${interface} up |
51 |
ExecStart=/bin/ifconfig ${tap_name} up 0.0.0.0 promisc |
52 |
ExecStart=/sbin/brctl addif ${bridge_name} ${tap_name} ${interface} |
53 |
ExecStart=/sbin/sysctl net.ipv4.conf.${bridge_name}.forwarding=1 |
54 |
ExecStart=iptables -t nat -A POSTROUTING -o ${interface} -j MASQUERADE |
55 |
ExecStart=/bin/ip route add default via ${gateway} |
56 |
|
57 |
ExecStop=/bin/ip route del default via ${gateway} |
58 |
ExecStop=/sbin/sysctl net.ipv4.conf.${bridge_name}.forwarding=0 |
59 |
ExecStop=/bin/ifconfig ${tap_name} down |
60 |
ExecStop=/sbin/brctl delif ${bridge_name} ${tap_name} |
61 |
ExecStop=/usr/bin/tunctl -d ${tap_name} |
62 |
ExecStop=/bin/ifconfig ${bridge_name} down |
63 |
ExecStop=/bin/ifconfig ${interface} down |
64 |
ExecStop=/sbin/brctl delbr ${bridge_name} |
65 |
ExecStop=iptables -t nat -D POSTROUTING -o ${interface} -j MASQUERADE |
66 |
|
67 |
[Install] |
68 |
WantedBy=multi-user.target |
69 |
|
70 |
---------- |
71 |
|
72 |
I disabled network.service and enabled bridge.service, works fine so |
73 |
far, I already tested connectivity from KVM-VMs. |
74 |
|
75 |
I am sure that this quite fresh and bloody, suggestions welcome as |
76 |
always ... |
77 |
|
78 |
Stefan |