Changes To Setting up bridge interface
Not logged in

Changes to "Setting up bridge interface" between 2015-12-18 07:38:04 and 2016-04-13 14:35:42

37
38
39
40
41
42
43

44
45
46


47

48
49
50
51


52
53
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84

85
86
87
88
89
90
91
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88
89
90

91
92
93
94
95
96
97
98







+



+
+

+




+
+











+
















-
+




-
+








    auto vm0
    iface vm0 inet static
         address 192.168.9.1
         network 192.168.9.255
         netmask 255.255.255.0
         bridge_ports none
         bridge_hw 11:22:33:44:55:66

(of course you can peek any number from 0 to 255 instead of 9 here for third octet of the IP. You can also use addresses from 10.0.0.0/8 or 172.16.0.0/12 instead of 192.168.0.0/16)

You need bridge_hw line (peek any unused mac address you want) because some recent versions of windows recognize bridge interface without static MAC as new network each time they boot.

Interface created this way would be totally isolated from outside world. This is probably not what you want, because you'll at least need to access software updates for your guest os. So, add following line:


    post-up iptables -t nat -A POSTROUTING -s 192.168.9.0/24 -j MASQUERADE

and don't forget to enable ipv4 forwaring in the kernel.



Really it is enough for bridge configuration, if you don't mind to setup static IP for each of your VM manually. But using dnsmasq would save you great deal of effort if you have more then 2-3 virtual machine.

RHEL, CentOS etc
----------------

Create file **ifcfg-vm0** in the /etc/sysconfig/network-scripts with following content

     TYPE=Brigde
     ONBOOT=yes
     DEVICE=vm0
     MACADDR=11:22:33:44:%5:66
     IPADDR0=192.168.9.1
     NETMASK0=255.255.255.0
     NM_CONTROLLED=no

Iptables rules for NAT should be added to  /etc/sysconfig/iptables

dnsmasq
=======

**dnsmasq** is a small dhcp and DNS server. If you would run it, it would act as caching DNS for your host machine and also provide IP Addresses for virtual machines and resolve their names.

You need to be sure that it servers DHCP only to your virtual bridge network, not to the physical network which connects you to internet, or it would conflict with dhcp server on your router and cause a mess.

So, you should have at least following lines in your dnsmasq.conf

    no-dhcp-interface=eth0
    domain=local.vm,192.168.199.0/24
    domain=local.vm,192.168.9.0/24
    dhcp-range=192.168.9.10,192.168.9.150,12h

First line specifies, that your ethernet interface shouldn't be served DHCP by dnsmasq. If your primary interface is wlan0 list it as no-dhcp-interface instead. If you have more than one physical network interface, repeat no-dhcp-interface line for each of them.

Second line tells dnsmask to tell virtual machines that they have local.vm domain (you may pick any other if yo want)
Second line tells dnsmask to tell virtual machines that they have local.vm domain (you may pick any other if you want)

And third line specifies range of addresses to give virtual machines, and time for which it this address is valid (12 hours). 

Also add 192.168.9.1 into your /etc/hosts with name of you host and local.vm domain, and make sure that your resolv.conf points to local host (0.0.0.0 or 127.0.0.1 as nameserver) and lists local.vm domain in search statement.

With this setup you'll be able to access all your virtual machines using their hostnames, set up during guest OS installations.