0

For testing, I am interested in way of programming a server to pretend to be configurable remote servers, i.e. have a server on my network acting as a router, but instead of forwarding packets to the public network, it would allow me to handle them locally. Is there any software, framework, library or platform that does this, preferrable running on Linux?

1 Answer 1

0

In the typical home situation, your router is running a DHCP server, and will give its own IP/subnet mask as the default gateway/subnet mask. This is what makes other computers on the network use it as a router, unless you configure them statically.

The isc-dhcp-server package under Debian, for example, will let you run a DHCP server on a PC. You should disable the one on your router first otherwise it's pure chance which one clients will listen to.

If your clients use DNS to determine what IP to connect to, at this point you can set up your own DNS server with bind, set up small local authoritative to catch specific hostnames, and configure it to forward to the rest to your ISP's nameservers, or other public DNS provider such as Google, OpenDNS, or OpenNIC.

If the remote service uses certificates to verify who it's connecting to, it will fail or produce warnings as this is a man-in-the-middle attack.

A Linux system can forward between two network adapters, if two are installed. Many home routers are exactly this - a Linux kernel running on a MIPS or ARM CPU. A search will provide many tutorials on how to enable port forwarding and get it running with NAT, using iptables. In this case, your home router would be taken out of the mix entirely, unless you wanted to use it for wireless (and you wouldn't be using the "router" part of your router, just the WLAN).

And in that iptables configuration you can setup REDIRECT targets that will transparently catch outgoing traffic towards specific IPs and redirect it to other IPs, such as your local IPs or those in a DMZ.

And, if the remote service uses certificates to verify who it's connecting to, it will fail or produce warnings as this is a man-in-the-middle attack.

Be prepared for some study with bind and iptables. Implementation details are too much to provide here, but it's completely possible.

2
  • Thank you for an very extensive reply! I am looking for something along these lines, but where I have programmatic control over each new TCP connection established (and incoming UDP packet). Is there a way for me to get callbacks for these events in C or, ideally a high level language like Python? Nov 24, 2014 at 19:10
  • Look into NFQUEUE target. For real-world example, look at nfblock.
    – LawrenceC
    Nov 24, 2014 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .