作者归档:Windows Hao

关于Windows Hao

力求做到最好的数据恢复效果,降低数据丢失带来的损失,为您的数据安全保驾护航。

设置iptables之后不能正常访问ftp解决方法

设置了iptables的禁止所有的端口,只容许可能访问了策略后大部分情况下会出现ftp不能正常访问的问题,因为ftp有主动和被动连接两种模式,少添加一些策略就会出问题。
在这里我就相信的说明下解决方法:
首先加载:
#modprobe ip_conntrack_ftp
#modprobe ip_nat_ftp
然后加载策略
#iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -I INPUT -p tcp --dport 21 -j ACCEPT
#iptables -I OUTPUT -p tcp --dport 21 -j ACCEPT
如果不想每次都加载模块的话请在 /etc/sysconfig/iptables-config
添加

201009231285213452593

保存之后皆可。

Linux上iptables防火墙的基本应用教程

iptables是Linux上常用的防火墙软件,下面给大家说一下iptables的安装、清除iptables规则、iptables只开放指定端口、iptables屏蔽指定ip、ip段及解封、删除已添加的iptables规则等iptables的基本应用。

1、安装iptables防火墙

如果没有安装iptables需要先安装,CentOS执行:
yum install iptables
Debian/Ubuntu执行:
apt-get install iptables

2、清除已有iptables规则

iptables -F
iptables -X
iptables -Z

3、开放指定的端口

#允许本地回环接口(即运行本机访问本机)
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
# 允许已建立的或相关连的通行
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#允许所有本机向外的访问
iptables -A OUTPUT -j ACCEPT
# 允许访问22端口
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#允许访问80端口
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#允许FTP服务的21和20端口
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
#如果有其他端口的话,规则也类似,稍微修改上述语句就行
#禁止其他未允许的规则访问
iptables -A INPUT -j REJECT (注意:如果22端口未加入允许规则,SSH链接会直接断开。)
iptables -A FORWARD -j REJECT

4、屏蔽IP

#如果只是想屏蔽IP的话“3、开放指定的端口”可以直接跳过。
#屏蔽单个IP的命令是
iptables -I INPUT -s 123.45.6.7 -j DROP
#封整个段即从123.0.0.1到123.255.255.254的命令
iptables -I INPUT -s 123.0.0.0/8 -j DROP
#封IP段即从123.45.0.1到123.45.255.254的命令
iptables -I INPUT -s 124.45.0.0/16 -j DROP
#封IP段即从123.45.6.1到123.45.6.254的命令是
iptables -I INPUT -s 123.45.6.0/24 -j DROP

5、查看已添加的iptables规则

iptables -L -n

v:显示详细信息,包括每条规则的匹配包数量和匹配字节数
x:在 v 的基础上,禁止自动单位换算(K、M)
n:只显示IP地址和端口号,不将ip解析为域名

6、删除已添加的iptables规则

将所有iptables以序号标记显示,执行:
iptables -L -n --line-numbers
比如要删除INPUT里序号为8的规则,执行:
iptables -D INPUT 8

7、iptables的开机启动及规则保存

CentOS上可能会存在安装好iptables后,iptables并不开机自启动,可以执行一下:
chkconfig --level 345 iptables on
将其加入开机启动。
CentOS上可以执行:service iptables save保存规则。
另外更需要注意的是Debian/Ubuntu上iptables是不会保存规则的。
需要按如下步骤进行,让网卡关闭是保存iptables规则,启动时加载iptables规则:
创建/etc/network/if-post-down.d/iptables 文件,添加如下内容:
#!/bin/bash
iptables-save > /etc/iptables.rules
执行:chmod x /etc/network/if-post-down.d/iptables 添加执行权限。
创建/etc/network/if-pre-up.d/iptables 文件,添加如下内容:
#!/bin/bash
iptables-restore < /etc/iptables.rules
执行:chmod x /etc/network/if-pre-up.d/iptables 添加执行权限。
关于更多的iptables的使用方法可以执行:iptables --help或网上搜索一下iptables参数的说明。

Linux Busybox Qt Grub2 开发环境与配置整套解决方案

VirtualSys_x86_Linux_Ubuntu_14.04_CN-2014-12-07-11-12-46

Linux项目说明

 

修正日期:2014/11/25

目录

项目要求... 3

Linux内核编译... 3

目录内容介绍(LinuxProject/LinuxKernel/) 3

内核配置中需要注意... 3

Qt框架... 6

目录内容介绍(LinuxProject/ Qt-EmbAndDesktop/) 6

Qt开发环境配置... 7

Qt版本添加... 7

LinuxProjectQt/Desktop版本添加... 7

LinuxProjectQt/E版本添加... 8

Qt构建套件添加... 9

LinuxProjectQt/Desktop版本添加... 9

LinuxProjectQt/E版本添加... 10

Qt Creator开发环境添加“帮助”(开发文档)... 10

Grub2(支持“安全启动”)... 12

目录内容介绍(LinuxProject/Grub2/) 12

统BIOS创建的目录结构... 12

EFI BIOS创建的目录结构... 13

BusyBox工具... 13

目录内容介绍(LinuxProject/BusyBox/) 13

库... 14

Glib. 14

目录内容介绍(LinuxProject/lib/glib/) 14

Libiconv. 14

目录内容介绍(LinuxProject/lib/libiconv/) 14

其它介绍... 14

Linux项目根目录脚本介绍... 14

Other目录文件介绍... 17

给本Linux项目传递参数... 18

与操作系统结合... 18

传统BIOS引导方式(LegacyBIOSBoot)... 18

EFI BIOS引导方式(EFIBIOSBoot)... 19

自动选择内核... 19

注意事项... 20

其它... 21

命令行编译Qt实例配置... 21

环境变量... 21

测试环境变量设置是否生效... 22

进入需要编译的程序目录(程序名hello.cpp)... 22

使嵌入式Qt支持中文字体的方法... 22

修改Qt Framebuffer模式背景(从png图片载入当做背景)... 22

判断当前Qt库是否为嵌入式版本... 23

Qt Creator IDE字体样式... 23

Qt应用程序“国际化”... 23

其它约定... 24

SVN客户端工具PySVN安装命令... 24

SVN命令行工具安装命令... 24

Qt X11风格样式设置... 24

用到的lib库... 27

注释... 28

 


 

项目要求

操作系统版本

Linux Ubuntu 14.04 x86

 

其它代码版本

Linux 内核:linux-3.17.4

Qt框架:qt-everywhere-opensource-src-4.8.6

Grub2:grub-2.02~beta2

BusyBox工具:busybox-1.22.1

 

Glib库:glib-2.6.6

Libiconv库:libiconv-1.14

 

开发环境

Qt Creator 3.2.2

 

Linux内核编译

编译x86与x86_64版本的内核,x86内核屏蔽EFI平台启动选项,x86_64内核支持EFI平台启动。

 

目录内容介绍(LinuxProject/LinuxKernel/)

linux-3.17.4.tar.xz:Linux内核源代码压缩包

.config - x86:x86 Linux内核配置文件(在Linux默认是隐藏的,如果想查看此文件,需要显示隐藏文件。)

.config - x64:x64 Linux内核配置文件(在Linux默认是隐藏的,如果想查看此文件,需要显示隐藏文件。)

mk-LinuxKernel-all.sh:Linux内核编译脚本文件

NoSimplifyConfig:存放没有精简过的内核配置文件(.config)

 

编译后在目录中生成:x86与x86_64两个文件夹,分别存放x86与x86_64内核文件,内核文件名为:bzImage。

 

内核配置中需要注意

。 。。。 。。。 。。。

Windows server 2008 搭建VPN服务

VPN英文全称是“Virtual Private Network”,就是“虚拟专用网络”。

虚拟专用网络就是一种虚拟出来的企业内部专用线路、这条隧道可以对数据进行几倍加密达到安全使用互联网的目的。
此项技术已被广泛使用、虚拟专用网可以帮助远程用户、公司分支机构、商业伙伴及供应商同公司的内部网建立可信的安全连接,用于经济有效地连接到商业伙伴和用户的安全外联网虚拟专用网。

实验环境:

服务器系统:Windows server 2008

客户机系统:Windows server 2003

 

服务器双网卡

外网卡IP:192.168.2.253

内网卡IP:172.16.2.253

 

客户机IP:

26

 

最终效果:客户机拨入VPN访问服务器内网、同时通过VPN服务器继续访问互联网

 

一、安装VPN服务

打开服务器管理器-添加角色

26

勾选网络策略和访问服务

26

下一步

26

勾选需要安装的服务:如图

26

下一步

26

开始安装

26

安装完成

26

 

二、配置VPN服务

当安装完路由和远程访问默认是禁用的,看到的是红下箭头,需要进行配置才变绿

26

右击路由和远程访问-配置并启动路由与远程访问

26

选择自定义-下一步

26

26

配置完启动服务

26

已经可以看到变绿了!

26

 

展开以后-右击NAT-新增接口

26

 

 

选择本地接口-公用接口(连接互联网),并在此接口上启用NAT,不然客户机拨号进来就只能访问服务器内网,无法连接互联网

26

26

 

右击NAT-新增接口-内部-专用接口 (连接虚拟专用网络)

26 26

右击路由和远程访问-属性-IPv4-静态地址池(用于指定客户机拨入VPN后,分配的IP范围,我指定IP是:172.16.2.100-200)

26

创建一个名为sky的VPN用户-属性-允许拨入

26

26

 

客户机测试

1、测试能否正常拨入

2、测试能否访问服务器内网和互联网

26 26 26

查看客户机成功拨入后的IP信息!

26

Qt for Embedded Linux Environment Variables

These environment variables are relevant to Qt for Embedded Linux users.

Variable Description
POINTERCAL_FILE Specifies the file containing the data used to calibrate the pointer device.See also QWSCalibratedMouseHandler and Qt for Embedded Linux Pointer Handling.
QT_ONSCREEN_PAINT If defined, the application will render its widgets directly on screen. The affected regions of the screen will not be modified by the screen driver unless another window with a higher focus requests (parts of) the same region.Setting this environment variable is equivalent to setting the Qt::WA_PaintOnScreen attribute for all the widgets in the application.See also the Qt for Embedded Linux graphics rendering documentation.
QWS_SW_CURSOR If defined, the software mouse cursor is always used (even when using an accelerated driver that supports a hardware cursor).
QWS_DISPLAY Specifies the display type and framebuffer. For example, if the current shell is bash, ksh, zsh or sh:

The valid values for the <driver> argument are LinuxFb, QVFb, VNC, Transformed, Multi and keys identifying custom drivers, and the <display num> argument is used to separate screens that are using the same screen driver and to enable multiple displays (see the Running Qt for Embedded Linux Applications documentation for more details).

The driver specific options are described in the display management documentation.

QWS_SIZE Specifies the size of the Qt for Embedded Linux window which is centered within the screen. For example, if the current shell is bash, ksh, zsh or sh:

QWS_MOUSE_PROTO Specifies the driver for pointer handling. For example, if the current shell is bash, ksh, zsh or sh:

The valid values for the <driver> argument are MouseMan, IntelliMouse, Microsoft, VR41xx, LinuxTP, Yopy. Tslib and keys identifying custom drivers, and the driver specific options are typically a device, e.g., /dev/mouse for mouse devices and/dev/ts for touch panels.

Multiple keyboard drivers can be specified in one go:

Input will be read from all specified drivers. Note that the Vr41xx driver also accepts two optional arguments: press=<value> defining a mouseclick (the default value is 750) and filter=<value> specifying the length of the filter used to eliminate noise (the default length is 3). For example:

See also Qt for Embedded Linux Pointer Handling.

QWS_KEYBOARD Specifies the driver and device for character input. For example, if the current shell is bash, ksh, zsh or sh:

The valid values for the <driver> argument are SL5000, Yopy, VR41xx, TTY, USB and keys identifying custom drivers, and the driver specific options are typically a device, e.g., /dev/tty0.

Multiple keyboard drivers can be specified in one go:

Input will be read from all specified drivers.

See also Qt for Embedded Linux Character Input.