如何为新启动的网络进程更改网络

时间:2015-09-24 07:36:48

标签: linux network-programming systems-programming

我想更改网络,但仅适用于新启动的流程。

我的想法是为新创建的进程修改/proc文件系统。如何在linux中做到这一点?

ruby​​中的示例代码

script.rb

conn = Tcp.dial('123.123.123.4', 3306)

和我的包装过程开始:

p = Process.new('script.rb')

# I would like to  somehow cheat a proc system
# so process during connection to 123.(...) connects really to localhost
# a bit like
# sudo iptables -t nat -A OUTPUT -p all -d 123.123.123.4 -j DNAT --to-destination 127.0.0.1
# but for process
p.network(from: '123.123.123.4', to: :localhost)

p.start

0 个答案:

没有答案