今天在虚拟机中突然需要虚拟打印,就稍微折腾了一下,免得虚拟机中软件装得过多,占空间,
在Fedora 17中做法如下:
1.先安装虚拟打印机和虚拟网卡工具:
yum install cups cups-pdf tunctl
2.打开端口:
管理->防火墙,勾选网络打印服务器
3.在浏览器中配置打印机:
网址是localhost:631
点击Administration,勾选 Share printers connected to this system,Allow printing from the Internet,Allow users to cancel any job (not just their own)
点击change settings
4.建立虚拟网卡:
a修改/etc/sysctl.conf
其中:
net.ipv4.ip_forward=1
b新建文件/etc/rc.d/rc.local
输入:
#!/bin/bash
tunctl -t tap0
ifconfig tap0 10.0.2.2 netmask 255.255.255.0 up
iptables -t nat -A POSTROUTING -o p35p1 -s 10.0.2.0/24 -j MASQUERADE
其中p35p1是自己机器的网卡名
然后保存,加运行权限
c.重启计算机