Python的re模块(正则表达式操作)
2013-07-16 22:55
906 查看
virtualbox 自带的网络配置模式要么选择host-only,要么bridge,对于经常使用virtualbox的同学一定想要像vmware一样的nat配置,既可以让host访问guest,又可以让guest访问外部网络
下面是安装步骤
1. 建立桥接网络
apt-get install bridge-utils
修改/etc/network/interfaces
增加以下内容:
####################################################
# VirtualBox NAT bridge
auto vnet0
iface vnet0 inet static
address 172.16.0.1
netmask 255.255.255.0
bridge_ports none
bridge_maxwait 0
bridge_fd 1
up iptables -t nat -I POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
down iptables -t nat -D POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
####################################################
up网卡
sudo ifup vnet0
2. 启用ip 转发
修改/etc/sysctl.conf 去掉这行的注释
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
运行下面命令使其生效
sysctl -p
3. 为虚拟机搭建dhcp服务器和dns服务器
apt-get install dnsmasq
修改/etc/dnsmasq.conf
去掉下面的注释
# Include a another lot of configuration options.
#conf-file=/etc/dnsmasq.more.conf
conf-dir=/etc/dnsmasq.d
在/etc/dnsmasq.d/目录下面增加一个名为virtualbox的文件,内容为:
#######################################
interface=vnet0
dhcp-range=172.16.0.2,172.16.0.254,1h
dhcp-option=option:dns-server,172.16.0.1,208.67.222.222,208.67.220.220
dhcp-option=option:domain-name,precision-m65
# mac地址 , 主机名, 分配的ip
dhcp-host=08:08:27:00:00:02,vmxp,172.16.0.20 # Windows XP
dhcp-host=08:08:27:00:00:03,vmubuntu,172.16.0.30 # Ubuntu
#######################################
4.修改virtualbox 虚拟机配置
a. 打开虚拟机配置
b. 选择网络
c. 选择Attached to: "Bridged Adapter"
Name: "vnet0"
Advanced-> Mac Address:080827000002 #对应3步中virtualbox给虚拟机分配的mac地址,注意去掉冒号
d. 应用生效
启动虚拟机,看看是不是分配了正确的地址,上面配置在ubuntu 10.04 LTS上测试通过,其他发行版类似
下面是安装步骤
1. 建立桥接网络
apt-get install bridge-utils
修改/etc/network/interfaces
增加以下内容:
####################################################
# VirtualBox NAT bridge
auto vnet0
iface vnet0 inet static
address 172.16.0.1
netmask 255.255.255.0
bridge_ports none
bridge_maxwait 0
bridge_fd 1
up iptables -t nat -I POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
down iptables -t nat -D POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
####################################################
up网卡
sudo ifup vnet0
2. 启用ip 转发
修改/etc/sysctl.conf 去掉这行的注释
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
运行下面命令使其生效
sysctl -p
3. 为虚拟机搭建dhcp服务器和dns服务器
apt-get install dnsmasq
修改/etc/dnsmasq.conf
去掉下面的注释
# Include a another lot of configuration options.
#conf-file=/etc/dnsmasq.more.conf
conf-dir=/etc/dnsmasq.d
在/etc/dnsmasq.d/目录下面增加一个名为virtualbox的文件,内容为:
#######################################
interface=vnet0
dhcp-range=172.16.0.2,172.16.0.254,1h
dhcp-option=option:dns-server,172.16.0.1,208.67.222.222,208.67.220.220
dhcp-option=option:domain-name,precision-m65
# mac地址 , 主机名, 分配的ip
dhcp-host=08:08:27:00:00:02,vmxp,172.16.0.20 # Windows XP
dhcp-host=08:08:27:00:00:03,vmubuntu,172.16.0.30 # Ubuntu
#######################################
4.修改virtualbox 虚拟机配置
a. 打开虚拟机配置
b. 选择网络
c. 选择Attached to: "Bridged Adapter"
Name: "vnet0"
Advanced-> Mac Address:080827000002 #对应3步中virtualbox给虚拟机分配的mac地址,注意去掉冒号
d. 应用生效
启动虚拟机,看看是不是分配了正确的地址,上面配置在ubuntu 10.04 LTS上测试通过,其他发行版类似
相关文章推荐
- Python的re模块正则表达式操作
- Python的re模块正则表达式操作
- Python之re模块 - 正则表达式操作
- Python之re模块 —— 正则表达式操作
- Python之re模块 —— 正则表达式操作
- python爬虫主要就是五个模块:爬虫启动入口模块,URL管理器存放已经爬虫的URL和待爬虫URL列表,html下载器,html解析器,html输出器 同时可以掌握到urllib2的使用、bs4(BeautifulSoup)页面解析器、re正则表达式、urlparse、python基础知识回顾(set集合操作)等相关内容。
- Python之re模块 —— 正则表达式操作
- Python之re模块 —— 正则表达式操作
- Python之re模块 —— 正则表达式操作[转]
- python_re模块 —— 正则表达式操作
- Python之re模块 —— 正则表达式操作
- Python之re模块 —— 正则表达式操作
- python学习笔记正则表达式re模块
- Python 正则表达式 RE模块的使用方法
- Python中re(正则表达式)模块学习
- 【python学习】re模块——正则表达式
- [整理] python的正则表达式re模块的常用方法
- python中利用re模块使用正则表达式
- Python 正则表达式 Re模块的一些简单入门知识
- Python学习笔记6-Python中re(正则表达式)模块学习