Rootop 服务器运维与web架构

2018-02-02
发表者 Venus
私接路由器导致内网网关冲突已关闭评论

私接路由器导致内网网关冲突

公司内有人私自加路由器,而且是直接连接LAN口,还不是接WAN口。就导致公司机器以为这台路由器是网关。导致断网。
默认家庭路由登陆ip(网关)基本都是 192.168.1.1 直接导致跟公司路由LAN口地址冲突,360之类的就会报arp攻击。

公司路由日志里可以看到冲突的mac地址是0c-72-2c-29-d9-ee,在本机手动添加ip地址和mac地址的映射,然后去访问那台私接的路由。
内网通讯用mac地址
公网通讯用ip地址
关于arp的作用不做阐述

添加arp映射:
在win10下老提示拒绝访问。
C:\WINDOWS\system32>arp -s 192.168.1.1 0c-72-2c-29-d9-ee
ARP 项添加失败: 拒绝访问。

换一种方法:
C:\WINDOWS\system32>netsh i i show in

Idx Met MTU 状态 名称
— ———- ———- ———— —————————
11 70 1500 disconnected WLAN
12 25 1500 disconnected 本地连接* 2
1 75 4294967295 connected Loopback Pseudo-Interface 1
36 35 1500 connected 以太网 3

Idx 36是我usb转网口的设备,连接公司内网,在这个设备上添加映射。

C:\WINDOWS\system32>netsh -c “i i” add neighbors 36 “192.168.1.1” “0c-72-2c-29-d9-ee”
路由IP mac地址

C:\WINDOWS\system32>arp -a

接口: 192.168.1.121 — 0x24
Internet 地址 物理地址 类型
192.168.1.1 0c-72-2c-29-d9-ee 静态

然后用浏览器去访问路由器的管理界面,一般都带无线,根据无线信号强弱每个楼层去找,然后问。
搞定

# 删除arp表映射
C:\WINDOWS\system32>arp -d
# 查看arp表映射
C:\WINDOWS\system32>arp -a

2018-01-24
发表者 Venus
php安装rabbitmq模块已关闭评论

php安装rabbitmq模块

官网下载:
http://pecl.php.net/package/amqp
根据自己php版本去找合适的amqp版本。

下载以后,压缩包有有两个dll文件。

php_amqp.dll 放到php的ext目录,配置php.ini加载此模块
rabbitmq.1.dll 这个放到system32下,否则调不出来amqp模块。

PS:
网上其它有文章说修改apache配置文件加一句loadfile 加载 rabbitmq.1.dll,那么用nginx的咋办?

2018-01-18
发表者 Venus
开启docker的远程连接 api接口已关闭评论

开启docker的远程连接 api接口

docker自带api接口,需要手动开启。

这里是yum安装的docker,版本是1.12

[root@localhost ~]# vi /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd-current \
 --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
 --default-runtime=docker-runc \
 --exec-opt native.cgroupdriver=systemd \
 --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
 $OPTIONS \
 $DOCKER_STORAGE_OPTIONS \
 $DOCKER_NETWORK_OPTIONS \
 $ADD_REGISTRY \
 $BLOCK_REGISTRY \
 $INSECURE_REGISTRY\
 $REGISTRIES\ # 不要忘记此换行
 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2222 # 添加的

# 重启docker服务
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
Warning: docker.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.

# 提示先执行 systemctl daemon-reload
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@localhost ~]# netstat -tnlp | grep 2222
tcp6 0 0 :::2222 :::* LISTEN 5750/dockerd-curren

2018-01-18
发表者 Venus
windows下安装pip已关闭评论

windows下安装pip

1、安装setuptools
官网:https://pypi.python.org/pypi/setuptools#downloads
下载以后,解压。
C:\Python27\setuptools-38.4.0>python setup.py install

2、安装pip
官网:https://pypi.python.org/pypi/pip/
下载以后,解压。
C:\Python27\pip-9.0.1>python setup.py install

然后就可以安装模块了
C:\Users\Administrator>c:\Python27\Scripts\pip.exe install paramiko

2018-01-04
发表者 Venus
django初试已关闭评论

django初试

版本 python2.7 需要django 1.11.x版本

https://github.com/django/django

解压
安装
python setup.py install

创建一个项目:
[root@localhost home]# django-admin startproject djtest

启动服务:
[root@localhost djtest]# python manage.py runserver
Performing system checks…

System check identified no issues (0 silenced).
# 报错
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run ‘python manage.py migrate’ to apply them.

解决:
[root@localhost djtest]# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial… OK
Applying auth.0001_initial… OK
Applying admin.0001_initial… OK
Applying admin.0002_logentry_remove_auto_add… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying sessions.0001_initial… OK

[root@localhost djtest]# python manage.py runserver 0.0.0.0:9999
监听所有ip的9999端口

2、访问django报错
Invalid HTTP_HOST header: ‘192.168.1.41:9999’. You may need to add u’192.168.1.41′ to ALLOWED_HOSTS.
修改 settings.pyALLOWED_HOSTS = []ALLOWED_HOSTS = [‘*’]