Category: Life

  • 现在的我失去了很多想法

    以前遇到问题总是能想到解决办法

    为什么现在会认为很多事情是很难办到的呢?
    总是皱眉头,还表现的很苦逼

    对于困难也会像 人们面对灾难或者死亡的情况

    denial anger bargaining depression acceptance

    不能放弃,想办法知道自己想做什么.

  • mysql replace命令

    将某字符串中的xz替换为yz

    select replace('xxxxxzccss','xz','yz');

    把Object表,字段asset_no中的XZZC替换为GDZC

    update `Object` set `asset_no`=REPLACE(`asset_no`,'XZZC','GDZC');

     

  • 2014读书清单

    目标60本书

    开始时间 技术书 非技术书 教学视频
    2014-02-16 毛泽东传
    2014-03-16 NoSQL数据库入门
    2014-04-03 Redis入门指南 番茄工作法图解
    2014-05-03 MacTalk人生元编程
    2014-05-23 mysql必知必会 黑客与画家
    2014-06-10 vim实用技巧
    2014-07-13 Introduction to Tornado 黑铁时代
    2014-07-19 一只特立独行的猪
    2014-08-19 沉默的大多数
    2014-10-1 devops故障排除
    2014-10-10 1984
    2014-11-02 node即学即用
    2014-12-1 江村经济
  • ubuntu使用3G无线网卡

    现在主流的3G无线网卡有电信和联通。

    ubuntu桌面版使用3g无线网卡步骤如下(联通):

    1.插上无线网卡后,lsusb,显示有当前品牌的无线网卡:

    Bus 002 Device 016: ID 12d1:1436 Huawei Technologies Co., Ltd.

    2.顶部网络管理器会多出一个Mobile Broadband,点击弹出向导

    选择设备->选择国家China->运营商China Unicom->计费策略Default-> apply

    之后弹出A password is required to connect to ‘China Unicom Default’

    输入密码为: 任意字符,连接完成。比windows装一大堆驱动,拨号和没用的软件方便多了。

    打开创建好的可以查看Mobile Broadband详情

    Number: *99#
    Username: uninet
    APN:uninet

    terminal下使用ifconfig命令,可以看到ppp0的链接

    ppp0      Link encap:Point-to-Point Protocol  
              inet addr:10.35.251.95  P-t-P:10.64.64.64  Mask:255.255.255.255
              UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
              RX packets:6 errors:0 dropped:0 overruns:0 frame:0
              TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:3 
              RX bytes:102 (102.0 B)  TX bytes:141 (141.0 B)

    使用电信无线网卡如下连接信息可参考(windows可用自带拨号连接):

    Dail number: #777
    Username: card
    Password: card

    使用移动无线网卡

    Access number: *99***1#
    Username: 空
    Password: 空
    APN: cmnet

    使用联通无线网卡

    电话号码: *99#

  • lsmod modinfo modprobe查看启用内核模块

    lsmod为查看内核模块,查看的原文件是/proc/modules
    modinfo后面跟上具体模块,可查看信息
    modprobe可以添加或删除模块

    查看有无bridge模块

    # lsmod | grep bridge
    bridge 79078 0
    stp 2218 1 bridge
    llc 5546 2 bridge,stp

    查看具体bridge模块的信息

    modinfo bridge
    filename: /lib/modules/2.6.32-358.el6.x86_64/kernel/net/bridge/bridge.ko
    version: 2.3
    license: GPL
    srcversion: 10C5CB47F80758600F32F24
    depends: stp,llc
    vermagic: 2.6.32-358.el6.x86_64 SMP mod_unload modversions

    有时连接 pptp vpn 连接不上是由于没有加载 ip_gre 引起的
    加载 ip_gre

    /sbin/modprobe ip_gre >/dev/null 2>&1

    开机启动自动加载模块

    cat /etc/sysconfig/modules/ip_gre.modules
    /sbin/modprobe ip_gre >/dev/null 2>&1

    需要有执行权限

    chmod +x ip_gre.modules
  • ip rule和 ip route

    相对ip route ,ip rule是高级路由,能实现不同条件路由的转发。

    linux系统维护了路由表,用ip rule show可以查看路由表。

    # ip rule show
    0: from all lookup local 
    32766: from all lookup main 
    32767: from all lookup default

    路由表记录在/etc/iproute2/rt_tables文件中,默认里面会用这么几行,在这个文件里添加的路由表即时生效

    255 local
    254 main
    253 default
    0 unspec

    所以自定义一个路由表的时候,序号要在1-252之间,路由选择的优先级也与数字的大小有关,越小的优先级越高,先匹配。
    数字后面要规定一个别名,方便使用和辨认。

    这样路由表的查看可有以下两种方法:

    ip route list table table_number
    ip route list table table_name

    如查看默认路由表可用如下命令

    ip route list table main
    ip route list table 254

    路由表添加完之后,接下来就是对路由表的操作,如果我有

    eth1 配置ip 192.168.1.8/24 路由表 101 mytable1

    eth2 配置ip  192.168.2.8/24 路由表 102 mytable2

    不同段的从不同的网卡走。

    ip route add 192.168.1.0 dev eth1 src 192.168.1.8 table mytable1
    ip route add default via 192.168.1.1 table mytable1
    ip rule add from 192.168.1.8 table mytable1
    
    ip route add 192.168.2.0 dev eth2 src 192.168.2.8 table mytable2
    ip route add default via 192.168.2.1 table mytable2
    ip rule add from 192.168.2.8 table mytable2

    现在使用ip rule show查看

    # ip rule show
     0: from all lookup local
     32764: from 192.168.2.8 lookup mytable2
     32765: from 192.168.1.8 lookup mytable1
     32766: from all lookup main
     32767: from all lookup default

    这时要删除rule可使用

    ip rule del prio 32764

    ip rule还可以实现更高级的功能,比如根据ip目的地址,包大小来进行转发。

    查看route -n flag

    The flags

    Following is the list of flags and their significance in the routing table :

    U : This flag signifies that the route is up
    G : This flag signifies that the route is to a gateway. If this flag is not present then we can say that the route is to a directly connected destination
    H : This flag signifies that the route is to a host which means that the destination is a complete host address. If this flag is not present then it can be assumed that the route is to a network and destination would be a network address.
    D : This flag signifies that this route is created by a redirect.
    M : This flag signifies that this route is modified by a redirect.