Host-only:主机想和虚拟机通信时使用

NAT :虚拟机想通过主机IP上网时使用

Bridged:虚拟机直接连接到物理网络时使用

Q:如果主机想和虚拟机正常通信又想能上网怎么办?

A:添加两个网卡,一个Host-only,一个NAT

参考:http://www.cnblogs.com/itech/archive/2011/02/12/1952836.html

CentOs下查看新添加网卡物理地址:
 
vi /etc/udev/rules.d/70-persistent-net.rules 
 
 
参考:http://blog.chinaunix.net/uid-28776492-id-3959991.html
 
 
chkconfig --list     #查看开机启动的服务
chkconfig httpd on   #开机启动httpd服务
chkconfig httpd off   #把开机启动httpd服务关闭

chkconfig --add httpd  #不常用,增加httpd服务
chkconfig --del httpd   #不常用,删除httpd服务
chkconfig --level httpd 2345 on #设置httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态

参考:http://www.cnblogs.com/panjun-donet/archive/2010/08/10/1796873.html

#Centos web环境配制

yum -y install mysql mysql-server mysql-devel httpd php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc mlocate

chkconfig --levels 235 httpd on
chkconfig --levels 235 mysqld on

~/.ssh/known_hosts    #ssh登录提示"Host key verification failed."时,把文件中的相应主机的条目删除即可

ifconfig eth0 192.168.0.100 netmask 255.255.255.0     #修改ip地址

route add default gw 192.168.0.254                    #修改default gateway

#将Centos的源替换成aliyun的
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo #查看eth0的mac地址
cat /sys/class/net/eth0/address #以可读方式查看硬盘分区大小
[root@localhost src]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.4G 5.4G 643M 90% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/sda1 97M 28M 65M 30% /boot #查看当前加载的磁盘
fdisk -l #给磁盘分区
fdisk /dev/sdbb #格式化磁盘
mkfs.ext4 /dev/sdbb1 #查看系统中磁盘的文件系统类型
df -T #显示磁盘的uuid
ls -l /dev/disk/by-uuid #系统启动时自动挂载磁盘,修改/etc/fstab
UUID=28b42ca0-54ce-4728-91e4-fb6f1efaa8ad /opt ext4 defaults 1 2 #禁止ping系统
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all #修改ssh默认端口
1)vi /etc/ssh/sshd_config
Port=22
修改成
Port=其他端口 2)service sshd restart #curl基本使用
curl "http://192.168.2.1" -X GET
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "foo=bar" http://192.168.2.1/ #nginx中隐藏yii2的url中的index.php
location / {
try_files $uri $uri/ /index.php?$args;
} #nginx中包含其他conf文件
http {
include /usr/local/nginx/conf/vhost/*.conf;
} #设置mysql的用户的密码
update mysql.user set password=password('pass') where user='username'; #iptables映射端口到外网地址
iptables -t nat -A PREROUTING -d 192.168.2.1 -p tcp --dport 3389 -j DNAT --to-destination 115.239.210.1:3389
iptables -t nat -A POSTROUTING -d 115.239.210.1 -p tcp --dport 3389 -j SNAT --to 192.168.2.1 #内网机器通过代理上网 [1]
iptables -t nat -I POSTROUTING -s 192.168.2.0/24 -j SNAT --to-source 192.168.1.1 #ssh限制ip登录 [1]
/etc/hosts.allow 中添加允许登录的地址 sshd:192.168.220.164:allow
/etc/hosts.deny 中禁所有ip登录 sshd:ALL #svn账户信息存放地址
/root/.subversion/servers #通过yum用其他源安装git [1]
yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
yum --disablerepo=base,updates,ius,epel install git #git编译安装
wget https://www.kernel.org/pub/software/scm/git/git-2.13.1.tar.gz yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker ./configure --prefix=/usr/local/git --without-tcltk make NO_CURL=1 NO_MSGFMT=YesPlease NO_TCLTK=YesPlease NO_GETTEXT=YesPlease #CentOS安装jdk、设置java环境变量
rpm -ivh dk-8u131-linux-x64.rpm
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin #linux用户添加 [1]
useradd user1 #增加user1用户,但不建立home目录,不设置用户密码,用户不可登录
userdel user1 #删除user1用户,不删除home目录 #samba设置密码 [1]
touch /etc/samba/smbpasswd //smb.con中修改
passdb backend = smbpasswd
smb passwd file =/etc/samba/smbpasswd smbpasswd -a user1 #增加samba用户user1
smbpasswd user1 #修改samba用户user1密码
smbpasswd -d user1 #禁用samba用户user1
smbpasswd -e user1 #重新启用samba用户user1
smbpasswd -x user1 #删除samba用户user1 #samba配置实例 [1]
[test]
comment = Public Share Dir
path = /home/samba_test
#writable = yes
writable = no
public = yes
guest ok = yes
create mask = 0664
directory mask = 0664
force user = root
force group = root
browseable = yes
available = yes
#allow hosts = 192.168.1.12 #在系统中增加用户
useradd -M -N -s /sbin/nologin -d /dev/null u_zhangsan #给用户设置samba密码
smbpasswd -a u_zhangsan #删除访问unc路径时填写的密码
net use \\192.168.1.2\user1 /del #CentOS下快速搭建web服务器
cd /etc/pki/rpm-gpg
wget http://repo.mysql.com/RPM-GPG-KEY-mysql #mysql56.repo [1]
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql yum install mysql-community-server #/etc/my.conf的[mysqld]下增加
character-set-server=utf8 #数据库启动后执行 mysql_secure_installation 初始化 #查看数据库初始化密码
grep 'temporary password' /var/log/mysqld.log #重新初始化数据库
mysqld --initialize #nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1 yum install nginx #AB POST数据,-V参数打印response(如果windows下要用双引号) [1]
ab -V 4 -n 2 -c 1 -p post.txt -T "application/x-www-form-urlencoded;charset=UTF-8" "http://192.168.2.1" #post.txt文件中内容格式
a=1&b=2 #AB 发送json请求
ab -n 2 -c 1 -p post_json.txt -T "application/json;charset=UTF-8" http://192.168.2.1 #post_json.txt文件中内容格式
{"page":1,"per_page":4,"sort_key":2,"sort_value":2} #Curl发送Json请求(Linux下)
curl 'http://192.168.2.1' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-binary '{"page":1,"per_page":4,"sort_key":2,"sort_value":2}' \
--compressed #通过grep将配置文件中的注释过滤
grep ^[^\;] php-fpm.conf
grep ^[^#] options.pptpd
grep -v "^\s\{1,\}#" smb.conf
grep -v "^\s\+#" smb.conf #Linux指定可以访问特定程序的IP [1]
1. 在先拒绝所有IP连接。
/etc/hosts.deny 中设置:
sshd:ALL
2. 添加允许连接的IP。
/etc/hosts.allow
sshd:192.168.2.2,192.168.2.3:allow #curl提交的数据放在body中(DOS下) [1]
curl -X POST -H "Content-Type:application/xml; charset=UTF-8" --data "<xml><appid><![CDATA[wx3511159573baf794]]></appid></xml>" http://localhost:8000/ #查看内存使用情况
free -h #curl访问链接并保存存文件,如果重定向则访问重定向后的内容
curl -L -o axios.js https://unpkg.com/axios/dist/axios.js

最新文章

  1. 夏夏的php开发笔记开写啦
  2. Pyunit测试框架
  3. Android深度探索--HAL与驱动开发----第二章读书笔记
  4. JavaScript的递归之更多例子
  5. javascript实现验证身份证号的有效性并提示
  6. 谈谈java中的volatile
  7. [DeeplearningAI笔记]神经网络与深度学习人工智能行业大师访谈
  8. spring boot 全局配置属性一览
  9. [Objective-C语言教程]协议(31)
  10. 201904Online Human Action Recognition Based on Incremental Learning of Weighted Covariance Descriptors
  11. centos7.5安装VirtualBox
  12. linux单用户模式
  13. POJ 2057 The Lost Home 树形dp 难度:2
  14. python中if __name__ == &#39;__main__&#39;: 解析
  15. php缓存类 内置output_buffer(ob)
  16. jQuery 数据 - jQuery.data() 方法
  17. hadoop本地化运行
  18. Centos6.5 安装gitlab 并使用自带的nginx
  19. python实现文件下载的方法总结
  20. SP1716 GSS3 - Can you answer these queries III(单点修改,区间最大子段和)

热门文章

  1. apache activemq 学习笔记
  2. 仅在TabControl中的Tab中添加右键菜单
  3. iOS之04-方法的声明和实现
  4. hbase 问题记录
  5. 《隆重介绍 思源黑体:一款Pan-CJK 开源字体》
  6. Coder-Strike 2014 - Round 1 E. E-mail Addresses
  7. Java中集合Set的用法
  8. eclipse安装color theme插件
  9. 【POJ3667】Hotel
  10. Bug:播放页面自动跳到首页