Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

18.17. 笔​​​​​​​记​​​​​​​本​​​​​​​配​​​​​​​置​​​​​​​

The task of configuring your RHEL 5.1 loaded laptop for use on a network environment, presents a number of potential challenges. Most WiFi and wired connections switch constantly during any given day, and Red Hat Virtualization assumes it has access to the same interface consistently. This results in the system performing ifup/ifdown calls to the network interface in use by Red Hat Virtualization. WiFi cards are not the ideal network connection method since Red Hat Virtualization uses the default network interface.
The idea here is to create a 'dummy' network interface for Red Hat Virtualization to use.
This technique allows you to use a hidden IP address space for your guests and Virtual Machines. To do this operation successfully, you must use static IP addresses as DHCP does not listen for IP addresses on the dummy network. You also must configure NAT/IP masquerading to enable network access for your guests and Virtual Machines. You should attach a static IP when you create the 'dummy' network interface.
在​​​​​​​这​​​​​​​个​​​​​​​例​​​​​​​子​​​​​​​里​​​​​​​,接​​​​​​​口​​​​​​​被​​​​​​​称​​​​​​​为​​​​​​​ dummy0,IP 地​​​​​​​址​​​​​​​为​​​​​​​ 10.1.1.1。​​​​​​​脚​​​​​​​本​​​​​​​被​​​​​​​称​​​​​​​作​​​​​​​ ifcfg-dummy0 并​​​​​​​位​​​​​​​于​​​​​​​ /etc/sysconfig/network-scripts/ 目​​​​​​​录​​​​​​​下​​​​​​​。​​​​​​​
DEVICE =dummy0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
IPV6INIT=no
PEERDNS=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=10.1.1.1
ARP=yes
你​​​​​​​应​​​​​​​该​​​​​​​把​​​​​​​ xenbr0 绑​​​​​​​定​​​​​​​至​​​​​​​ dummy0 ,这​​​​​​​样​​​​​​​即​​​​​​​使​​​​​​​和​​​​​​​物​​​​​​​理​​​​​​​网​​​​​​​络​​​​​​​断​​​​​​​开​​​​​​​,这​​​​​​​也​​​​​​​可​​​​​​​以​​​​​​​允​​​​​​​许​​​​​​​网​​​​​​​络​​​​​​​连​​​​​​​接​​​​​​​。​​​​​​​
You will need to make additional modifications to the xend-config.sxp file. You must locate the ( network-script 'network-bridge' bridge=xenbr0 ) section and add include this in the end of the line:
netdev=dummy0
You must also make some modifications to your guest's domU networking configuration to enable the default gateway to point to dummy0. You must edit the DomU 'network' file that resides in the /etc/sysconfig/ directory to reflect the example below:
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=10.1.1.1
			
IPADDR=10.1.1.10
NETMASK=255.255.255.0
启​​​​​​​用​​​​​​​ domain0 里​​​​​​​的​​​​​​​ NAT 是​​​​​​​个​​​​​​​好​​​​​​​主​​​​​​​意​​​​​​​,这​​​​​​​样​​​​​​​ domU 就​​​​​​​可​​​​​​​以​​​​​​​访​​​​​​​问​​​​​​​公​​​​​​​共​​​​​​​网​​​​​​​络​​​​​​​。​​​​​​​用​​​​​​​这​​​​​​​种​​​​​​​方​​​​​​​式​​​​​​​,即​​​​​​​使​​​​​​​是​​​​​​​无​​​​​​​线​​​​​​​用​​​​​​​户​​​​​​​也​​​​​​​可​​​​​​​以​​​​​​​绕​​​​​​​过​​​​​​​红​​​​​​​帽​​​​​​​虚​​​​​​​拟​​​​​​​化​​​​​​​系​​​​​​​统​​​​​​​的​​​​​​​无​​​​​​​线​​​​​​​限​​​​​​​制​​​​​​​。​​​​​​​如​​​​​​​下​​​​​​​例​​​​​​​所​​​​​​​示​​​​​​​,要​​​​​​​实​​​​​​​现​​​​​​​这​​​​​​​种​​​​​​​方​​​​​​​法​​​​​​​,你​​​​​​​必​​​​​​​须​​​​​​​修​​​​​​​改​​​​​​​ /etc/rc3.d 目​​​​​​​录​​​​​​​里​​​​​​​的​​​​​​​ S99XenLaptopNAT 文​​​​​​​件​​​​​​​。​​​​​​​
#!/bin/bash
#
# XenLaptopNAT  Startup script for Xen on Laptops
#
# chkconfig: - 99 01
# description: Start NAT for Xen Laptops
#
# PATH=/usr/bin:/sbin:/bin:/usr/sbin
# export PATH
GATEWAYDEV=`ip route | grep default | awk {'print $5'}`
iptables -F
case "$1" in
start)
if test -z "$GATEWAYDEV"; then
echo "No gateway device found"
else
echo "Masquerading using $GATEWAYDEV"
/sbin/iptables -t nat -A POSTROUTING -o $GATEWAYDEV -j MASQUERADE
fi
echo "Enabling IP forwarding"
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "IP forwarding set to `cat /proc/sys/net/ipv4/ip_forward`"
echo "done."
;;
*)
echo "Usage: $0 {start|restart|status}"
;;
esac
如​​​​​​​果​​​​​​​你​​​​​​​想​​​​​​​在​​​​​​​引​​​​​​​导​​​​​​​时​​​​​​​自​​​​​​​动​​​​​​​设​​​​​​​置​​​​​​​网​​​​​​​络​​​​​​​,你​​​​​​​必​​​​​​​须​​​​​​​创​​​​​​​建​​​​​​​ /etc/rc3.d/S99XenLaptopNAT 的​​​​​​​软​​​​​​​链​​​​​​​接​​​​​​​。​​​​​​​
在​​​​​​​修​​​​​​​改​​​​​​​ modprobe.conf 文​​​​​​​件​​​​​​​时​​​​​​​,你​​​​​​​必​​​​​​​须​​​​​​​包​​​​​​​括​​​​​​​下​​​​​​​面​​​​​​​的​​​​​​​行​​​​​​​:
alias dummy0 dummy
options dummy numdummies=1