IP in VPN vs. LAN: alias IP address by iptables

Sceneria: while your are at work you are on LAN and you use 192.168.x.x. But once you do home office you connect by VPN to the same DB and the IP changes to 10.x.x.x. And you don’t wanna change configs for your app 🙁

Using IP tables that can be worked around easily:

# Enable IP forwarding
sudo sh -c 'echo "1" > /proc/sys/net/ipv4/ip_forward'

# LAN IP
IP_LAN=192.168.3.38

# VPN IP
IP_VIRTUAL=10.8.4.38

ping -c 1 -W 1 $IP_VIRTUAL                                                 
PING 10.8.4.38 (10.8.4.38) 56(84) bytes of data.
64 bytes from 10.8.4.38: icmp_seq=1 ttl=63 time=124 ms

ping -c 1 -W 1 $IP_LAN                                                          PING 192.168.3.38 (192.168.3.38) 56(84) bytes of data.

--- 1.23.23.2 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

sudo iptables -t nat -A PREROUTING -d $IP_LAN -j DNAT --to-destination $IP_VIRTUAL
sudo iptables -t nat -A POSTROUTING -j MASQUERADE

ping -c 1 -W 1 $IP_LAN
PING 192.168.3.38 (192.168.3.38) 56(84) bytes of data.
64 bytes from 192.168.3.38: icmp_seq=1 ttl=63 time=125 ms

Laptop Perfomance: irqbalancer vs. intel_pstate

Today I uninstalled irqbalancer and I had some more performance gain on my GNOME desktop.

The CPUfreq control panel showed me IRQBALANCE DETECTED and they say:

Why I should not use a single core for power saving

  • Moderns OS/kernel work better on multi-core architectures.
  • You need at least 1 core for a foreground application and 1 for background system services.
  • Linux Kernel switches between CPU cores to avoid overheating, CPU thermal throttling and to balance system load.
  • Many CPUs have Hyper-Threading (HT) technology enabled by default. So there is no reason to run half of a physical CPU core.

Very simply said. I miss some contradictions.

I’m not certain how laptop drains battery running without intel_pstate=skylake_hwp set to disable. The pstate does make sense to me. Mainly I think it was irqbalancer. I have do do some stress testing later…