28 марта 2011 г.

debian vps ip alias

I needed my Debian VPS to show certain fake IP on ifconfig, so I've applied the following changes to /etc/network/interfaces file
# This configuration file is auto-generated.

# WARNING: Do not edit this file, your changes will be lost.
# Please create/edit /etc/network/interfaces.head and /etc/network/interfaces.tail instead,
# their contents will be inserted at the beginning and at the end
# of this file, respectively.
# NOTE: it is NOT guaranteed that the contents of /etc/network/interfaces.tail
# will be at the very end of this file.

# Auto generated lo interface
auto lo
iface lo inet loopback

# Auto generated venet0 interface
auto venet0
iface venet0 inet static
up route add -net %GATEWAY_IP% netmask dev venet0
up route add default gw %GATEWAY_IP%

auto venet0:0
iface venet0:0 inet static
address %REAL_IP%

If you're using VPS and those changes are getting overwritten on startup, create a new file /etc/network/interfaces.e and put the following script in cron @reboot:
cp /etc/network/interfaces.e /etc/network/interfaces
/etc/init.d/networking restart

Комментариев нет: