天天看點

linux用netcat做端口轉發

方法如下:

    $ mknod backpipe p

    建立一個命名管道.

    listener-to-client 轉發:

    $ nc -l -p [localport] 0< backpipe |

        nc [target ip] [port] |

        tee backpipe

    漂亮吧?

    繼續:

    listener-to-listener 轉發:

        nc -l -p [localport2] |

    client-to-client 轉發:

    $ nc [ip1] [port1] 0< backpipe |

        nc [ip2] [port2] |

    還有更雷的方法,用自身的 -e 參數:

    $ echo nc [ip] [port] > relay.sh

    $ chmod +x relay.sh

    $ nc -l -p [port2] -e relay.sh

文章如轉載,請注明轉載自【網管小王的獨立部落格】:http://www.5iadmin.com/

繼續閱讀