自己动手给国内外各种云重装纯净版的CentOS7.x(2)

自己动手给国内外各种云重装纯净版的CentOS7.x(2)

一些基于openstack(阿里云云服务器ECS、百度云服务器BCC、京东云服务器,腾讯云服务器CVM,青云QingCloud)的架构使用上面的无法进行安装,那么就需要调整下配置参数才能进行自行重装

是对自己动手给国内外各种云重装纯净版的CentOS7.x的补充
需要自己动手给国内外各种云重装纯净版的CentOS7.x或者其他Linux系统

1、
wget -O /boot/vmlinuz.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/initrd.img

镜像也可以使用各大云服务提供商私有的(通过repo和私有DNS)
-------------------------------------------------------------------------------------------------
2、
cd /etc/grub.d

vi 40_custom

将下面的信息添加进去
menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
linux16 /boot/vmlinuz.centos.pxe inst.headless ip=dhcp nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /boot/initrd.img.centos.pxe
}

insmod ext2
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这四项信息需要查看/boot/grub2/grub.cfg具体来设置

如果磁盘用的是GPT格式的,需要添加inst.gpt选项。 If you are using GPT disk add inst.gpt option.
linux16 /vmlinuz.centos.pxe inst.gpt inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe

3、重新生成/boot/grub2/grub.cfg
grub2-mkconfig -o /boot/grub2/grub.cfg

4、设置默认启动项
grub2-set-default www.zhangfangzhou.cn

5、grub2-editenv list #查看确认

6、reboot
打开vnc连接选择启动项www.zhangfangzhou.cn就可以重装了


自己动手给国内外各种云重装纯净版的CentOS7.x

自己动手给国内外各种云重装纯净版的CentOS7.x
需要自己动手给国内外各种云重装纯净版的CentOS7.x或者其他Linux系统
前文 自己动手给国内外各种云重装纯净版的CentOS6.x

CentOS7使用的是grub2,/boot/grub2/grub.cfg (由grub2-mkconfig -o /boot/grub2/grub.cfg生成)
-----------------------------------------------------------------------------------------------
1、国内
wget -O /boot/vmlinuz.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/initrd.img

国外
wget -O /boot/vmlinuz.centos.pxe http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/images/pxeboot/initrd.img
-------------------------------------------------------------------------------------------------
2、cd /etc/grub.d
ls
00_header 01_users 20_linux_xen 30_os-prober 41_custom
00_tuned 10_linux 20_ppc_terminfo 40_custom README

vi 40_custom

将下面的信息添加进去
menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe headless ip=122.114.224.36 noipv6 netmask=255.255.255.0 gateway=122.114.224.1 dns=114.114.114.114 ksdevice=eth0 method=http://mirrors.aliyun.com/centos/7/os/x86_64/ devfs=nomount lang=en_US keymap=us
initrd16 /initrd.img.centos.pxe
}

上面的IP、掩码、网关、修改为你机器的就可以

set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这三项信息需要查看/boot/grub2/grub.cfg具体来设置

----------------
正规写法

menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe
}

insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这四项信息需要查看/boot/grub2/grub.cfg具体来设置

如果磁盘用的是GPT格式的,需要添加inst.gpt选项。 If you are using GPT disk add inst.gpt option.
linux16 /vmlinuz.centos.pxe inst.gpt inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe

CentOS 6 CentOS 7
vnc inst.vnc
vncpassword= inst.vncpassword=
Note: MUST at least 8 char
headless inst.headless
ip= ip=ip::gateway:netmask:hostname:interface:none
Example:
ip=10.0.0.10::10.0.0.1:255.255.255.0:host.example.com:eth0:none or ip=dhcp
gateway= See IP above
netmask= See IP above
dns= nameserver=
method= inst.repo=
lang= inst.lang=
keymap= inst.keymap=

你可以阅读整个选项变化
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options
----------------

ls -l /etc/grub2.cfg
lrwxrwxrwx 1 root root 22 Oct 28 17:25 /etc/grub2.cfg -> ../boot/grub2/grub.cfg

3、重新生成/boot/grub2/grub.cfg
执行grub2-mkconfig -o /boot/grub2/grub.cfg

4、设置默认启动项
grub2-set-default www.zhangfangzhou.cn

5、grub2-editenv list #查看确认

6、reboot
打开vnc连接选择启动项www.zhangfangzhou.cn就可以重装了

7、信息补充
rhgb quiet
rhgb表示redhat graphics boot,就是会看到图片来代替启动过程中显示的文本信息,这些信息在启动后用dmesg也可以看到
quiet表示在启动过程中只有重要信息显示,类似硬件自检的消息不回显示

rhgb = redhat graphical boot - This is a GUI mode booting screen with
most of the information hidden while the user sees a rotating activity
icon spining and brief information as to what the computer is doing.
quiet = hides the majority of boot messages before rhgb starts. These
are supposed to make the common user more comfortable. They get alarmed
about seeing the kernel and initializing messages, so they hide them for
their comfort.

8、
也可以添加一些自定义的启动选项
menuentry "System shutdown" {
echo "System shutting down..."
halt
}

menuentry "System restart" {
echo "System rebooting..."
reboot
}

VMware Workstation 14运行虚拟机黑屏解决办法

VMware Workstation 14运行虚拟机黑屏解决办法
升级到VMware workstation 14 pro后所有虚拟系统全部黑屏,VMware 14 黑屏,VMware Workstation 14运行虚拟机黑屏是什么原因

步骤如下,
步骤如下,
1、以管理员身份运行命令提示符(cmd.exe),输入命令 netsh winsock show catalog可以看到VMware注册了两个LSP:vSockets DGRAM、vSockets STREAM,路径是%windir%\system32\vsocklib.dll
2、查看有没有其他模块也注册了vSockets DGRAM、vSockets STREAM,如果有,就卸载掉这个模块所属的软件。
3、在命令提示符输入netsh winsock reset,重启计算机后 VMware Workstation 14 可以正常使用(正常使用只要再次重启依然是黑屏,说明还是有程序干扰winsock )。
4、修改兼容性,创建虚拟机兼容性改为VMware workstation 12安装系统后,兼容性再改回VMware workstation 14,虚拟机依然是黑屏。
5、重装VMware Workstation 14(依然是黑屏黑屏)。
6、卸载鲁大师,使用360LSP修复工具修复winsock,重启后正常。
7、卸载腾讯WeGame游戏平台,使用360LSP修复工具修复winsock,重启后正常。

Linux服务器下rootkit后门检测工具chkrootkit安装使用

Linux服务器下rootkit后门检测工具chkrootkit安装使用
操作系统:CentOS6 7

一、安装编译工具包
yum install gcc gcc-c++ make glibc-static -y

二、安装chkrootkit
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz #下载软件包
tar -zxvf chkrootkit.tar.gz #解压
cd chkrootkit-0.52
make sense #安装
cd ..
mv chkrootkit-0.52 /usr/local/chkrootkit #拷贝到安装目录

三、使用chkrootkit

cd /usr/local/chkrootkit
./chkrootkit | grep INFECTED
出现INFECTED就说明系统可能有问题了

CentOS 7.x 可能会出现下面的提示,原因是系统默认缺少netstat命令chkrootkit: can't find `netstat'.
yum whatprovides *netstat #查看命令所在的安装包
yum install net-tools #安装netstat命令即可

自己动手给国内外各种云重装纯净版的CentOS6.x

自己动手给国内外各种云重装纯净版的CentOS6.x
随着互联网的发展,云计算规模越来越大,越来越大的公司开始做相关的产品,为了方便客户的使用很多云公司会优化使用的系统,(阿里云云服务器ECS、百度云服务器BCC、京东云服务器,腾讯云服务器CVM,青云QingCloud,景安云服务器和景安vps,快云服务器和快云vps)添加一些不必要的组件
为此需要自己动手给国内外各种云重装纯净版的CentOS6.9或者其他Linux系统

1、国内
wget -O /boot/vmlinuz.centos.pxe http://mirrors.aliyun.com/centos/6/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://mirrors.aliyun.com/centos/6/os/x86_64/images/pxeboot/initrd.img

国外
wget -O /boot/vmlinuz.centos.pxe http://repos-lax.psychz.net/centos/6/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://repos-lax.psychz.net/centos/6/os/x86_64/images/pxeboot/initrd.img

2、yum install grub -y
vi /boot/grub/menu.lst

修改default=0
把下面这段插入在hiddenmenu后面

title CentOS 6.9 www.zhangfangzhou.cn
root (hd0,0)
kernel /boot/vmlinuz.centos.pxe headless ip=23.225.182.142 noipv6 netmask=255.255.255.0 gateway=23.225.182.1 dns=8.8.8.8 ksdevice=eth0 method=http://repos-lax.psychz.net/centos/6/os/x86_64/ lang=en_US keymap=us
initrd /boot/initrd.img.centos.pxe

上面的IP、掩码、网关、修改为你机器的就可以

root (hd0,0)
kernel /boot/vmlinuz.centos.pxe
initrd /boot/initrd.img.centos.pxe
这三项信息需要查看/etc/grub.conf具体来设置

ls -l /etc/grub.conf
lrwxrwxrwx. 1 root root 22 Oct 18 08:53 /etc/grub.conf -> ../boot/grub/grub.conf

3、reboot
打开vnc连接就可以重装了

如果IP信息是通过DHCP的方式获取的,那么需要修改成下面的
title CentOS 6.9 www.zhangfangzhou.cn
root (hd0,0)
kernel /boot/vmlinuz.centos.pxe headless ip=dhcp dns=8.8.8.8 ksdevice=eth0 method=http://mirrors.aliyun.com/centos/6/os/x86_64/ lang=en_US keymap=us
initrd /boot/initrd.img.centos.pxe



使用 FRP 内网穿透| 适用于Linux Windows服务端

使用 FRP 内网穿透| 适用于Linux Windows服务端
1、很多情况下处于NAT网络环境中没有公网IP,这个时候可疑通过FRP服务器的转发进行内网穿透。frp内网穿透服务器搭建和frp使用方法。
本教程是使用TCP模式(连接内网Windows的远程桌面),frp客户端和frp服务端以Windows服务的方式在后台默默运行,还可以使用UDP、HTTP、HTTPS模式。
2、为什么不再使用ngork
ngork2.0不再开源

3、Linux服务端安装
wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh
chmod 700 ./install-frps.sh
./install-frps.sh install
或者手动安装
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_linux_386.tar.gz
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_linux_amd64.tar.gz
tar -zxvf frp_0.16.1_linux_amd64.tar.gz
mv frp_0.16.1_linux_amd64 frp
vi /etc/rc.local
su - root -c "/root/frp/frps -c /root/frp/frps.ini -L /root/frp/frps.log"

https://github.com/fatedier/frp/releases/download/v0.21.0/frp_0.21.0_linux_amd64.tar.gz
tar -zxvf frp_0.21.0_linux_amd64.tar.gz
mv frp_0.21.0_linux_amd64 frp
vi /etc/rc.local
su - root -c "/root/frp/frps -c /root/frp/frps.ini" #这样日志会在/root目录下

4、Windows服务端安装
https://github.com/fatedier/frp/releases
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_windows_386.zip
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_windows_amd64.zip
解压即可

5、frp服务端配置文件,基本包含frps_full.ini全部的配置了
frps.ini
---------------------------------------------------------------------------------------------------
[common]
bind_addr = 0.0.0.0
bind_port = 5443
# udp port used for kcp protocol, it can be same with 'bind_port'
# if not set, kcp is disabled in frps
kcp_bind_port = 5443

# set dashboard_addr and dashboard_port to view dashboard of frps
# dashboard_addr's default value is same with bind_addr
# dashboard is available only if dashboard_port is set
dashboard_addr = 0.0.0.0
dashboard_port = 7500

# dashboard user and pwd for basic auth protect, if not set, both default value is admin
dashboard_user = admin
dashboard_pwd = admin

# assets_dir = ./static
vhost_http_port = 8080
vhost_https_port = 4443
log_file = ./frps.log
# debug, info, warn, error
log_level = info
log_max_days = 30

# privilege mode is the only supported mode since v0.10.0
privilege_token = hLzzySjVo1kMJgaz
# heartbeat configure, it's not recommended to modify the default value
# the default value of heartbeat_timeout is 90
# heartbeat_timeout = 90

# only allow frpc to bind ports you list, if you set nothing, there won't be any limit
#privilege_allow_ports = 1-65535
# pool_count in each proxy will change to max_pool_count if they exceed the maximum value
max_pool_count = 50

# authentication_timeout means the timeout interval (seconds) when the frpc connects frps
# if authentication_timeout is zero, the time is not verified, default is 900s
authentication_timeout = 900

# if subdomain_host is not empty, you can set subdomain when type is http or https in frpc's configure file
# when subdomain is test, the host used by routing is test.frps.com
subdomain_host = frps.com

# if tcp stream multiplexing is used, default is true
tcp_mux = true

服务端简洁配置
[common]
bind_addr = 0.0.0.0
bind_port = 55443
kcp_bind_port = 55443
log_file = ./frps.log
log_level = info
log_max_days = 30
privilege_token = hLzzySjVo1kMJgaz
max_pool_count = 50
tcp_mux = true
authentication_timeout = 900
#frp_0.21会出现下面的错误,FRP 客户端所在机器和 FRP 服务端所在机器的时间相差不能超过 15 分钟
login to server failed: authorization faile
2018/09/27 14:31:15 [W] [service.go:262] authorization failed
-------------------
6、Windows 启动frp服务器
frps.exe -c frps.ini
Windows快速添加通过防火墙规则
netsh advfirewall firewall add rule name="Open Port 5443" dir=in action=allow protocol=TCP localport=5443
netsh advfirewall firewall add rule name="Open Port 5443" dir=in action=allow protocol=TCP localport=6443
netsh advfirewall firewall add rule name="Open Port 4443" dir=in action=allow protocol=TCP localport=4443
netsh advfirewall firewall add rule name="Open Port 23689" dir=in action=allow protocol=TCP localport=23689
netsh advfirewall firewall add rule name="Open Port 8080" dir=in action=allow protocol=TCP localport=8080

Windows 开机自启动frp服务器
控制面板 ---> 管理工具 ---> 任务计划程序

或者运行框输入下面代码,添加启动项 #这样必须登录系统才开始运行服务
%programdata%\Microsoft\Windows\Start Menu\Programs\Startup
-------------------
7、linux 启动frp服务器
frps -c frps.ini

Linux 开机自启动frp服务器
vi /etc/rc.d/rc.local #centos7 chmod +x /etc/rc.d/rc.local
su - root -c "/root/frp/frps -c /root/frp/frps.ini"

vi /etc/rc.local
su - root -c "/root/frp/frps -c /root/frp/frps.ini"
iptables -I INPUT -p tcp -m multiport --dports 55443,55446,55448 -j ACCEPT;service iptables save;service iptables restart
---------------------------------------------------------------------------------------------------
8、客户端配置文件tcp_model
frps.ini
----------
[common]
server_addr = 122.114.xx.xx
server_port = 5443
log_file = ./frpc.log
log_level = info
log_max_days = 30
privilege_token = hLzzySjVo1kMJgaz
pool_count = 50
tcp_mux = true
login_fail_exit = true
protocol = tcp
[tcp_mode]
privilege_mode = true
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 23689

验证登录远程桌面122.114.xx.xx:23689

[ssh]
# tcp | udp | http | https | stcp | xtcp, default is tcp
type = tcp
local_ip = 127.0.0.1
local_port = 22
# true or false, if true, messages between frps and frpc will be encrypted, default is false
use_encryption = false
# if true, message will be compressed
use_compression = false
# remote port listen by frps
remote_port = 6001
# frps will load balancing connections for proxies in same group
group = test_group
# group should have same group key
group_key = 123456
--------------
9、客户端配置文件http_model
[common]
server_addr = 122.114.xx.xx
server_port = 5443
log_file = ./frpc.log
log_level = info
log_max_days = 30
privilege_token = hLzzySjVo1kMJgaz
pool_count = 50
tcp_mux = true
login_fail_exit = true
protocol = http
[web]
type = http
local_ip = 127.0.0.1
local_port = 80
use_encryption = false
use_compression = false
subdomain = frp.asuhu.com
-------------------
启动客户端
frpc.exe -c frpc.ini

Linux下逐行比较两个文本文件

Linux很多情况下需要逐行比较两个文本文件,并显示出两个文件中所有不同的行。推荐使用diff和vimdiff(需要安装vim)
很多情况下需要逐行比较两个文本文件,并显示出两个文件中所有不同的行。推荐使用diff和vimdiff(需要安装vim)

vimdiff zhuzhan20170830 zhuzhan20170831
:qa! #退出

cat diffzhuzhan20170831
--- /root/checkdir/zhuzhan20170830 2017-08-30 07:05:03.250349499 +0800
+++ /root/checkdir/zhuzhan20170831 2017-08-31 07:05:02.523044481 +0800
@@ -93,10 +93,12 @@
367b63c971d06817126273caaf7520ff /baidu_push.php
47396f597f8b06e103c7d53014febc80 /vote/index.php
c509a365abe6ced5adb8d09ba59e993d /ViewClick/zt.php
+5d36bb18cf3d737672e856aa67281a2e /ViewClick/zhibojump.php
082a0ee07a3467779091d1d71980965f /ViewClick/ViewMore.php
-3dc18566881ef1420a6f8988cd1eefda /ViewClick/jump.php
-097555dcc2718ece2fac34070a14b1c2 /ViewClick/index.php
-ad168ec79acf8bf3861a099b08a7c0c8 /ViewClick/dell.php
+3dbe6a57c87f1d3d0fe6eef4bd1472bb /ViewClick/jump.php
+3d88ddf568f0279767cf671b10f63484 /ViewClick/index.php
+aa5ce6769a9a8e8e73a4c13aad24753f /ViewClick/dell.php
+40cd750bba9870f18aada2478b24840a /ViewClick/cacheZhiboJump.php
32c01ba72925465a3a437f41ffb9e4ee /uvonclick/index.php
477344028faf48e0cb70088a5cb4c266 /PPHD/index.php
f82b7e6311a0cff4af01092fd07a541f /onclick/index.php
--- /root/checkdir/zhuzhan20170830 2017-08-30 07:05:03.250349499 +0800
+++ /root/checkdir/zhuzhan20170831 2017-08-31 07:05:02.523044481 +0800
@@ -93,10 +93,12 @@

字母"a"、"d"、"c"分别表示添加、删除及修改操作
+ 比较的文件的后者比前着多一行
- 比较的文件的后者比前着少一行

显示结果分成三部分,
第一部分是文件的基本信息,“---”表示变动前的文件,“+++”表示变动后的文件。
第二部分,变动的位置用两个@作为起首和结束。@@ -93,10 +93,12 @@,前面的“-93,10”分成三个部分:减号表示第一个文件(即f1),“93”表示第93行,“10”表示连续10行,
合在一起,就表示下面是第一个文件从第93行开始的连续10行。同样的,“+93,12”表示变动后,成为第二个文件从第93行开始的连续12行。
第三部分是变动的具体内容,它将两个文件的上下文,合并显示在一起,每一行最前面的标志位,空表示无变动,减号表示第一个文件删除的行,加号表示第二个文件新增的行。

diff的输出可以做为补丁。
制作补丁:
  diff -urN linux-3.4.2 linux-3.4.2-my > linux-3.4.2-my.patch
打补丁:
  patch -p1 < ../linux-3.4.2-my.patch

华为Quidway S3300系列交换机,配置管理IP,清除console密码,配置telent和http密码

华为Quidway S3300系列交换机,配置管理IP,清除console密码,配置telent和http密码
华为Quidway S3300系列交换机清除console密码
1、使用console数据线加USB转串口线链接到console口
2、在重启交换机的时候,连续按Ctrl+B,进入BOOTROM memu (Press Ctrl+B to enter BOOTROM memu)
3、输入密码,如果没修改过的话,可能是huawei或者Admin@huawei.com
4、选择7 Cler password for console user,然后按1启动

华为Quidway S3300系列交换机配置管理IP
#system-view //进入系统视图
#interface vlanif 1 //进入vlan1接口视图
#ip address 192.168.0.2 255.255.255.0 //配置接口的IP地址
#display vlan 1

华为Quidway S3300系列交换机配置telent和http密码
1、输入console密码进入交换机界面
2、添加用户和密码
#aaa
#local-user admin password cipher huawei //admin的密码设置为huawei
#local-user h3c password cipher huawei //添加用户h3c,密码设置为huawei
#local-user admin privilege level 3 //设置账号级别,3为最高
#local-user h3c privilege level 3 //设置账号级别,3为最高 或者local-user h3c level 3
#local-user service-type telnet //设置本地账户服务类型是telnet
#quit
#user-interface vty 0 4
#authentication-mode aaa //设置登录用户的验证方式为aaa
#protocal bind telnet //绑定telnet协议
#protocal bind ssh

华为Quidway S3300系列交换机创建页面web网管账号
#system-view //进入系统视图
#http server enable //使能http服务
#aaa //进入aaa视图
#local-user huawei password cipher huawei //添加用户huawei,密码设置为huawei
#local-user huawei service-type http //huawei的访问类型为http
#q //返回系统视图
#www.zhangfangzhou.cn