Answer the question
In order to leave comments, you need to log in
How to set the primary IP address on a network interface?
Hello!
There are three IP addresses configured for one network interface:
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.42
netmask 255.255.255.0
gateway 192.168.1.1
auto eth0:0
iface eth0:0 inet static
address 192.168.1.43
netmask 255.255.255.0
auto eth0:1
iface eth0:1 inet static
address 192.168.1.44
netmask 255.255.255.0
Answer the question
In order to leave comments, you need to log in
You obviously have the main one - the 42nd. If you want to send via another - add a route or change the address to eth0.
Your output will be 192.168.1.42
If you want another, then the rules of iptables.
As an example, let's say you have ip 192.168.1.200 and you need to release it with ip 192.168.1.44:
iptables -A FORWARD -s 192.168.1.200 -j ACCEPT
iptables -A POSTROUTING -s 192.168.1.200 -o eth0 -j SNAT --to -source 192.168.1.44
this is specific in your case, just specifying any ip address will not work, only the one that is in the system, but there are those in the system that you have indicated above (well, to which the reverse route will be built, the left ip cannot be specified).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question