工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表全部文章

linux下用rinetd做端口转发

端口转发映射的程序叫rinetd,启动方法rinetd -c /etc/rinetd.conf 。

把1.1.1.1的11端口映射到2.2.2.2的3389端口,配置文件如下

[root@localhost iso]# cat /etc/rinetd.conf
1.1.1.1 11 2.2.2.1 3389
1.1.1.1 12 2.2.2.2 3389
1.1.1.1 13 2.2.2.3 22
1.1.1.1 14 2.2.2.4 80
allow *.*.*.*
logfile /var/log/rinetd.log

http://www.boutell.com/rinetd/

tcpshow(1) - Linux man page

Name

tcpshow - decode a tcpdump savefile

Synopsis

tcpshow [ -b ] [ -sb ] [ -w width ] [ -nolink ] [ -noip ]

[ -nodata ] [ -data ] [ -track ] [ -terse ]
[ -cooked ] [ -pp ] [ -s ] [ -h ]
[ expression ]

Description

tcpshow reads a tcpdump(1) savefile and provides a reasonably complete decode of Ethernet, IP, ICMP, UDP and TCP headers, in packets that match the boolean expression. The data belonging to these packets is displayed in ASCII.

Currently, protocol data is not decoded. This is not considered a serious problem for applications that use ASCII data streams.

Also, IP and TCP options are not decoded.

The input file must be in the format produced by tcpdump -enx. This file can be generated from
1. a prior run of tcpdump -w file
2. a live run of tcpdump (without -w)
3. any other program that produces a correctly formatted
trace
See under EXAMPLES for each of these different methods, plus a description of the format the input file needs to be in.

Except when -cooked is used, tcpdump(1) is required to be on your PATH, to process the raw savefile.

Options

The following options can be used in just about any sane combination.

-b

break long lines so they don't wrap

This produces a neater, more readable display of the application data. The default width is 60 columns. See the -w flag for how to change this default.
-sb

show line breaks

When -b is used, it may be useful to see exactly where tcpshow wrapped each line, in its display of application data. This option causes the string ''<break>'' to be displayed at the end of each wrapped line. (Lines which were not wrapped, but terminated before the page width, are not so marked.)
-w width
set pagewidth to width columns
This determines where tcpshow will fold long lines, when the -b switch is used.
-nolink
don't decode the link header
The data link header (Ethernet header) is not decoded and displayed.
-noip

don't decode the IP header

The IP header is not decoded and displayed.
-nodata
don't show the data
The protocol data is not displayed (a count of data bytes is shown).
-data

display only the data

The data, plus a minimal decode of the IP and transport/ICMP headers, is displayed.
-track

track TCP sequence numbers

An additional field is produced in the output which shows the TCP acknowledgement number which this side of the connection should receive once the current packet has been received by its peer.
-terse

show the header decode in compact format

Without this option, the display of the decoded header is verbose, occupying a lot of display-space real-estate. With this option, the decoded header information is much more compact and terse. Once you're familiar with the meanings of the header fields, you'll probably always use this option. (Maybe this should be the default, with a -verbose flag to get long-winded header decodes?)
-cooked
don't run tcpdump(1) to pre-process the input
If the input file is already in the expected format, this option must be used. See EXAMPLES below of where this flag is appropriate.
-pp

point-to-point link

If the input file was collected from data travelling over a point-to-point link (one which doesn't make an Ethernet header available), this option needs to be used.
-s

also display a hex dump of spurious data at packet-end

For a reason unknown to the author, tcpdump(1) output sometimes contains data at the end of packets which don't belong to those packets. This spurious data is suppressed from the output, except when this option is used.
-h

display a help summary

This list of options is displayed, with one-liner descriptions.
expression
filter the input file using a tcpdump(1) expression
If the -cooked option is not used, then tcpdump(1) is required to be on your PATH. It is used to read the raw savefile, producing output in the format tcpshow expects. The expression should be a valid tcpdump(1) expression. It is not parsed or interpreted by tcpshow, but passed on to tcpdump(1) for its consumption.

Examples

In the following examples, where tcpdump(1) is used, the flag -s 1518 is used to be sure of saving the complete Ethernet frame.

Also, where tcpdump(1) expressions are used, these could equally have been given to tcpdump(1) directly, if it was known at this time what data you're interested in.

Capture a raw savefile and decode it later.

# tcpdump -s 1518 -w savefile
# tcpshow < savefile
Decode the data as quickly as tcpdump(1) gives it to us.
# tcpdump -s 1518 -lenx | tcpshow
Display headers only.
# tcpshow -nodata < savefile
Display data only (minimal header decode).
# tcpshow -data
Display a decode of Telnet traffic only, omitting the link and IP headers.
# tcpdump -s 1518 -w savefile
# tcpshow -nolink -noip tcp port telnet < savefile
Give a compact display of the TCP headers, and a full display of the data, for all packets going into or coming from the host "sam" -- this host is on a LAN accessible through a PPP link.
# tcpdump -i ppp0 -s 1518 -w savefile
# tcpshow -pp -terse host sam < savefile
Show all SMTP mail transfers, omitting the headers and wrapping the message bodies to make it easy to read them (you're not supposed to do this).
# tcpdump -s 1518 -w savefile
# tcpshow -b -w 40 -data port smtp < savefile
To display a decode of data not captured via tcpdump(1), you would typically use the application that captured the trace to dump that trace into a file in ASCII-hex format. You feed that file into a Perl/sh/awk script (that you write), which produces a file in the format tcpshow expects. Such scripts are easy to write. For example, if your application is "capture" and your script is "convert", then tcpshow might be used as follows.
# capture -hexoutput | convert | tcpshow
A loose definition of the format tcpshow expects is: the 1st line of each packet must begin in column 1. All other lines must begin with a TAB. The hex bytes can be separated from each other by any amount of whitespace, including none.
When using -cooked, the first field should be the time the packet was captured (or a string like "no-time-recorded" if the time isn't available). The remaining fields should be the bytes of the IP datagram.
When -cooked is not used, the first field should be as above, with the next three fields being the Ethernet source address, the Ethernet destination address and the DIX Ethernet Type field.

Files

tcpshow reads from standard input and writes to standard output.

See Also

tcpdump(1), nit(4P), bpf(4)

LVS笔记

在RS中建立一个lo:0接口,设置ip为vip地址。

当使用arping vip时,会有多个MAC地址回应,这是因为RS也响应的VS的arp查询。[code]sysctl -e net.ipv4.conf.all.arp_ignore=1[/code]复制代码

此时,RS即不再影响RS关于vip的ARP MAC查询了。

假如两台VS之间使用的互备关系,那么当一台VS接管LVS服务时,可能会网络不通,这时因为路由器的MAC缓存表里关于vip这个地址的MAC地址还是被替换的VS的MAC,有两种解决方法,一种是修改新VS的MAC地址,另一种是使用send_arp 命令(piranha软件包里带的一个小工具),格式如下:[code]send_arp

send_arp [-i dev] src_ip_addr src_hw_addr targ_ip_addr tar_hw_addr[/code]复制代码

这个命令不一定非要在VS上执行,只要在同一VLAN即可。

12-17:

今天对RS ARP MAC查询有了新的认识,网上大多数的文章都提到要用四个参数来关闭arp查询响应请求:[code]
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce[/code]复制代码
我的RS最近的流量也频繁出现“异常”,经分析是因为arp的问题,rs有时会夺取VS的ip援用权。使用以上四条之后,VS立刻有了流量。

1. LVS调度的最小单位是“连接”。
2. 当apache的KeepAlive被设置成Off时,“连接”才能被较均衡的调度。
3. 在不指定-p参数时,LVS才真正以“连接”为单位按“权值”调度流量。
4. 在指定了-p参数时,则一个client在一定时间内,将会被调度到同一台RS。
5. 可以通过”ipvsadm ?set tcp tcpfin udp”来调整TCP和UDP的超时,让连接淘汰得快一些。
6. 在NAT模式时,RS的PORT参数才有意义。
7. DR和TUN模式时,InActConn 是没有意义的(Thus the count in the InActConn column for LVS-DR, LVS-Tun is
inferred rather than real.)

什么是白卡机

近日,记者了解到水货手机市场上原本具备国外运营商网络锁的手机,多数商家仅简单的采用所谓“白卡”的方式进行解锁,并销售给消费者。这一现象也本使系统稳定的手机却只能以工程测试机的不稳定形式供消费者使用。

手机测试卡用作解锁卡 

  “白卡”是一种手机测试SIM卡,由于其一般颜色为白色,故被俗称为“白卡”,其被广泛应用于通讯工业生产及测试过程。手机测试卡本身用于测试显示手机、调节器版本,显示话音加密码、还原通话时间和误码率等方面的手机功能性测试。

据悉,现在主要测试卡有GSM、TD-SCDMA、WCDMA、CDMA、CDMA2000多种网络类型的支持。其卡身内存常用的有32K/64K/128K,并可根据不同的测试需求进行定制。

  近日,记者了解到一些水货市场中的商家普遍利用“白卡”对有国外运营商网络锁的手机进行解锁,使其被解锁的手机可以使用国内运营商的网络。而这一现象也使得专用于测试的“白卡”有了新的市场。

  另据记者了解,销售解锁“白卡”的分类与手机测试卡分类不同,网络类型多被以不同手机品牌或地区的划分所取代。如销售价约为65元左右的MrSIM解锁卡则专门针对解锁日*本运营商的网络锁而设计,主要适合NTTDocomo和Softbank手机的解锁。

  针对手机品牌的则有夏普手机解锁卡、iPhone手机解锁卡、NOKIA及索尼爱立信解锁卡、HTC解锁卡等。尽管卡的网络属性及针对品牌不同,但SIM卡样式基本相同,颜色也全部为白色。

  某销售“白卡”的商家表示,此卡主要销售对象为一些水货手机商或部分手机发烧友。

手机易变为工程测试机

      跟据市场调查发现,由于此种方法进行手机的解锁效率相对较高,水货市场上的多数商家均喜欢采取此种方式对含有外国网络锁的手机进行解锁,然后再销售给消费者并可插入我国运营商的SIM卡后使用。

  但记者针对此事采访相关进行手机启动项安装程序开发的人士时却得知,此种方法解锁的一些智能手机尽管可以正常使用,但实际上由于“白卡”为手机测试卡,用此卡解锁后的手机系统引导模式将被更改,当手机开机加载系统时将会加载入工程测试机的启动项。

  本身为正式销售的手机产品,“白卡”解锁在系统层却变为工程测试机,影响了用户使用手机时系统的稳定性。

  另有相关专业人士提示消费者,“白卡”解锁后的智能手机在二次刷机后还可脱离工程测试机属性,并跳出原有国外运营商的网络锁。只因步骤相对复杂,大部分水货销售商对此步骤进行了省略。建议消费者在熟悉所购买的手机后要求水货商进行二次刷机或进行自行刷机。

了解了白卡机的源头之后,再来看看怎样辨别是否白卡机:

1.机子从一开始入手至今,没自己去彻底root过,但是你发现你的机子进去FASTBOOT里面可以看到已经显示有”S-OFF”字样!(关机,按住返回键和电源键直到开机,三色英文字体的界面就是FASTBOOT,看最顶部一行英文后面显示“S-ON”还是“S-OFF”即可,我的就是S-OFF);

2.机子一到手至今开机就是个安智网的登录界面而不是原厂的开机界面也不是是Alpharev S-OFF第一屏,那就很大可能是工程机了(安置登录的最近好像少了,我的就是原厂开机界面,不知道是不是JS们换了另一个体面点的ROM);

3.试试更换你的第一屏吧!如果没权限会提示“no allowed”。

Android 什么是HTC白卡机和工程机、解锁方式SHIP S-OFF、ENG S-OFF

HTC安卓系统手机进入HBOOT界面显示的是 ACE PVT SHIP S-ON/OFF或者是 ACE PVT ENG S-ON/OFF,现对此显示进行深入了解(SHIP S-OFF、ENG S-OFF、软解、白卡解锁释疑)。

 

ACE: 这个是手机的内部代号

 

Desire HD这台 HTC版叫Desire HD 内部代号是 ACE

 

PVT : 这台机子的主板类型是PVT

关于主板,稍微说明下下哈,一台硬件设备上市前,其都经历过大量的实验以及修改,主板版本的不同代表了这台机子是什么时期的硬件

主板类型其实还有很多 EVT DVT CVT PVT 什么的

EVT:工程机 恭喜你了,你拿到了工程样机,说好听的多有纪念价值啊,说不好听的,这台机子跟上市的机子可能有很大硬件上的区别,基本上不要指望能跟大家用一样的ROM软件啥的

DVT:开发机 比EVT好点,硬件较稳定或接近稳定状态,但是基本也都存在跟正式版硬件上的差异,请更多关注纪念价值吧~

CVT:商试用机(认证机)拿来试用,交给运营商贴ok标签的机型,一般到这个版本,硬件是不会再去改动的了,和零售版不会有啥区别

PVT:最终量产机 不需解释了吧

这里一般不会有假的,大可放心(EVT,DVT数量极少,就算不小心流出市面,JS要是有能力改SPL信息的话,也早就不用做JS这行啦~) 如果你还不放心,告诉你,确认主板类型最保险的还是拆机直接看主板,主板上直接印有的,安心了吧~~

 

SHIP: 当前SPL版本

这个纠结的人多啊~~ 哈哈 这个是当前SPL的版本(SPL是啥?靠,完机器人怎能不知道呢?简单来说就是你这台手机的BIOS)

版本也有几个的 SHIP ENG DEV

SHIP: 原生版 也就是系统原生自带的SPL,处女膜SPL哦~

ENG: 工程版(自制版) 这里其实更多是自制的意思,也就是大神们修改过后的SPL

DEV: 开发版 极少有,对咱们终端用户意义不大的

 

S-OFF : 安全锁 OFF

S-ON:安全锁打开 CID校验 检测往里刷的东东副不符合CID校验,不符合的就砍你没商量

S-OFF: 安全锁关闭 SUPERCID

简单来说,S-OFF 关闭CID校验,刷ROM比较自由,权限最大,大部分自制ROM都要求关闭CID校验的,所以才有说S-ON刷不了这么一说

 

回到我们手上的机器

现在大家应该知道 白卡解的是SHIP S-OFF 软解的是 ENG S-OFF

看过上面的解释后,估计大家也就明白区别了

 

白卡就是那HTC内部的某神奇SIM卡,直接修改了安全锁校验为OFF 这本身就是官方内部的东西,只不过不知道JS通过什么手段拿到了这张官方SIM卡

对于白卡解的机子,并没有对原生SPL进行修改,所以还是SHIP版的 就只是安全锁OFF了

 

软解的机子,基本上都对SPL进行了操作修改,可以说并不是原生系统SPL了 所以显示版本为 ENG

 

那SHIP 和 ENG 有啥区别呢

原生的SPL 对于我们刷ROM是没有任何限制,但是对于刷RECOVERY和刷IMG是要验证签名的,这也是为啥下面替换开机画面那贴里所谓“白卡机用不了”的原因

而ENG的SPL,去掉了这些签名机制,可以直刷

但也并不是说SHIP版的就刷不了,跟ENG版的有些少不同罢了.

而且SPL本身是可以刷的,SHIP版ENG版,没啥所谓啦 反正刷ROM都一样的

Android名词解释:Recovery、Root、SPL、ROM、Radio等

想要玩好android,有一些词汇那是相当的重要,必须要牢记的。否则会给以后的刷机留下很大的麻烦。

什么?你说只玩游戏不刷机?那也要明白这些词,因为这些都是日常使用当中对你很有帮助的。比如为什么我的手机那么慢?为什么别的人桌面效果我没有?为什么我的手机信号总不好?为什么我的手机会出现灵异事件?

如果掌握了这些东西,就不会被自己身上发生的灵异事件吓到。即使吓到了,你也知道怎么在网上询问,其他网友也知道怎么跟你沟通。

 

Recovery
Recovery模式可以给你的android系统升级固件版本,升级系统版本,升级通讯基带版本,做APPtoSD,系统备份还原等等很多功能,所以一定一定要明白recovery。

进入recovery的方法也很简单,拿G1来说,按住小房子+电源进入就好了。

 

 


root
root权限和我们在windows系统的administrator权限一个意思 。root是android系统中的超级管理员用户帐户,该帐户拥有整个系统至高无上的权利,所有对象他都可以操作。(现在的手机,大部分都已经提取了root权限)

radio
Radio是无线通信模块的驱动程序,负责网络通信。

菜单->设置->关于手机->基带版本,看是不是62.50S.20.17H_2.22.19_26I。

升级系统一定要刷新最近的radio,而且新的radio对通信质量的帮助很大。属于比刷的东西。

 

 


SPL
SPL负责主板,电源、硬件初始化程序。SPL 一般提供这几部分功能:检测手机硬件、寻找系统启动分区、启动操作系统为系统的基本维护提供操作界面,可以通过数据线与操作终端建立连接,并接受和执行相应命令。

是否spl了 用超级终端:键入su 回车 再键入df 回车 看到data 91M的就是spl,其他则不是。


固件版本
固件是说操作系统的系统内核版本。就好像是电脑用的winXP,win7的样子。

目前最新的固件是【2.2】,但是个人比较倾向于【2.1】,经过几个改动,目前还是很稳定的。

ROM
ROM就和固件版本关系比较暧昧了。我还用刚才的例子打比方,固件是winXP,那么ROM就是XPsp3,是固件版本的细分。再或者说,比如是番茄花园的XP,枫林玉林的XP。

在linux上配置ipip隧道与routeros对接

IPIP是在两台主机之间的IP层上建立一条虚拟的通道(没有加密,没有压缩),相当于建立一条VPN.
下面是一个例子:

我们想在两台机器之间建立ipip,它们分别为:Router A 和 Router B. 它们分别都连接到网络上.
Router A:

外网地址是: 192.0.2.34 
内网地址是: 192.168.1.1
Router B:

外网地址是: 192.0.2.69
内网地址是:  192.168.1.254

在Router A上执行命令:
ip tunnel add tunnel0 mode ipip remote 192.0.2.69 local 192.0.2.34
ip link set tunnel0 up
ip addr add 192.168.1.1/24 dev tunnel0

在Router B执行命令:
ip tunnel add tunnel0 mode ipip remote 192.0.2.34 local 192.0.2.69
ip link set tunnel0 up
ip addr add 192.168.1.254/24 dev tunnel0Skip to 'testing the tunnel'.

Debian sample setup
Router A
Edit /etc/network/interfaces:

auto tunnel0
iface tunnel0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  pre-up /sbin/ip tunnel add tunnel0 mode ipip remote 192.0.2.69 local 192.0.2.34
  post-down /sbin/ip tunnel del tunnel0Then execute

ifup tunnel0.

Router B
Edit /etc/network/interfaces:

auto tunnel0
iface tunnel0 inet static
  address 192.168.1.254
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  pre-up /sbin/ip tunnel add tunnel0 mode ipip remote 192.0.2.34 local 192.0.2.69
  post-down /sbin/ip tunnel del tunnel0Then execute

ifup tunnel0

Testing your tunnel
After you have configured your tunnel via one of the examples above you should be able to ping the remote end:

Router A
ping 192.168.1.254

Router B
ping 192.168.1.1

Both pings should succeed without problems.

使用你建立的IP tunnel
You can now use your tunnel - just pretend it's a piece of Ethernet between the two computers.
Remember the MTU on the tunnel will be lower than normal because of the extra IP header.
You can setup routing and whatever you like over the tunnel.
If you lose your route to the tunnel endpoint, the tunnel will not work either.

--------------------------------------------------------------------------------

More complex situations
When tunneling between 2 routers, and 1 router has a private network on another interface, routing between the two can be confusing. Here is the network layout:

Router 1
eth0: 1.2.3.4 (public)Router 2
eth0: 4.3.2.1 (public)
eth1: 10.0.0.1In my particular case, Router 1 is an asterisk system on a public network, and Router 2 is a NAT router that is also a gateway for my private 10.0.0.0/24 network. I have multiple SIP phones (which don't work through NAT) on the 10.0.0.0/24 network and I need to establish routes between the 2.

IN THIS ORDER ENTER THESE COMMANDS

Router 1
iptunnel add iptun mode ipip remote 4.3.2.1
ifconfig iptun 10.0.1.1
route add -net 10.0.2.0/24 dev iptunRouter 2
iptunnel add iptun mode ipip remote 1.2.3.4
ifconfig iptun 10.0.2.1
route add -net 10.0.1.0/24 dev iptunRouter 1
route add -net 10.0.0.0/24 dev iptun
route add -net 10.0.0.0/24 gw 10.0.0.1Now from Router 2 you can ping any device on the 10.0.0.0/24 network behind Router 1, and from any device on the 10.0.0.0/24 network, you can ping Router 1 using the address 10.0.1.1

lvs iptun模式下realserver需要运行的脚本

$vip = 192.168.0.254

ifconfig tunl0 $vip netmask 255.255.255.255 broadcast $vip up
route add -host $vip dev tunl0
echo 1 > /proc/sys/net/ipv4/conf/all/hidden
echo 1 > /proc/sys/net/ipv4/conf/tunl0/hidden