• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Change socket sender IP

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've a VPS with 2 IP addresses (ip a and ip b). When I send packets with a socket, it sends allways with ip a. How can I change this so that it send with ip b?
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jochem,

the sender IP usually depends on the routing table(s) and network configuration of your OS. The network stack decides which interface to use for sending your packets based on the routing table and the IP address of this interface is automatically used as sender IP. This can be changed though. With Linux for example you can use an iptables postrouting rule to modify the sender IP just before the network packets leave your box. There are surely similar approaches for any modern OS.

Marco
 
reply
    Bookmark Topic Watch Topic
  • New Topic