1

Is there is any easy way to modify tcp socket parameters? For example: Server_program is using eth0 with 10.0.0.1, it can't be restarted and I need to recreate socket on the eth1 with 192.168.0.1. I know there is some other not trival problems but all I'm looking now is possibility to modify socket "on-the-fly" inside the kernel. Thank you for any advices.

2
  • The program's hardcoded to the 10.x IP? I doubt you could modify a socket in-memory to change its port/ip like that, short of being Linus, but perhaps the iptables stuff can internally do a redirect for you. Commented Feb 11, 2011 at 14:20
  • Marc B: But program connects with inode. Right? I need put program "on hold", modify socket informations and run program Commented Feb 13, 2011 at 19:30

1 Answer 1

2

Open the new socket, do whatever steps are needed to get it connected and into the same state, and then use dup2() to turn the old file descriptor into a clone of the new one.

Sign up to request clarification or add additional context in comments.

1 Comment

...and if you want to do this from outside, you can use ptrace() to debauch the target process as necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.