What does the 'primary address' mean about the interface [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
What does the primary address of interface mean?In my mind,there's only one address of one interface. Is this right?

No, you can assign additional "secondary" or "alias" addresses to an interface.
For example, this interface has 3 addresses. The primary is "127.0.0.1".
# ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648
inet 127.0.0.1 netmask 0xff000000
inet alias 192.168.1.200 netmask 0xffffffff
inet alias 192.168.140.200 netmask 0xffffffff
This means that this interface can accept packets addressed to all three of those addresses. It can also send using all three of those as it source address, but as Unix Network Programming says, you need to specifically bind to a secondary address as it will use the primary by default.
Why might you want to do this? Some reasons are:
You are changing a machine's IP address and want to accept traffic at
the old address for some period of time (say waiting for DNS changes
to propagate).
You are using anycasting or other High-Availability techniques where each
machine has its own address and there this a "service address" that can
move from machine to machine.
Your machine is acting as a routing device.

Related

/etc/network/interfaces: What's <eth>:<num> mean? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
In /etc/network/interfaces, I have a physical eth0 and a vlan eth0.10, however there is an additional eth0:0
iface eth0 inet manual
iface eth0.10 inet manual
vlan-raw-device eth0
iface eth0:0 inet manual
What does a colon mean in interfaces file? Is it the same as a dot?
Column in network interfaces mean virtual interface. Here is in Debian/Ubuntu:
[root#ubuntu ~]# cat /etc/network/interfaces
iface eth0:0 inet static
address 123.123.22.22
netmask 255.0.0.0
broadcast 123.255.255.255
For more info you can check here.
As far as I remember you can have up to 255 (or 256, not sure) virtual interfaces per physical one.
It is another network interface name. Linux accepts any string as the name of the network interface. eth0 is one network interface. eth1 is another. eth0:0 is another network interface. eth0!##$&*() may be another interface name. There is no special meaning in any : nor . nor any special characters in the interface name. Allowed chars in Linux network interface names?
Well, maybe except for meaning/interpretation. I would expect the interface named eth0:0 to be someone "binded"/"connected" with eth0. But that is (human) interpretation. I don't think linux binds any significance in how the network interface is named. For example, user on this question uses : for ip aliases and . to denote VLAN.
In your configuration the three network interfaces eth0, eth0.10 and eth0:0 are all configured using manual configuration. Check the output of cat /proc/net/dev or any of ip a or ifconfig ip config utilities to see what network interfaces are available on your machine.

New IP address does not persist after restart [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have some code that uses system commands to set the IP address and default gateway in Linux.
It works, but when the Linux OS is restarted, it reverts back to the old IP address.
Here are the commands used, addresses changed here.
ip link set eth1 down
ifconfig eth1 0.0.1.2 netmask 255.255.255.0
route add default gw 0.0.1.2 eth1
ip link set eth1 up
Is there another place in Linux where the IP address needs to be set, that 'ifconfig' does not change?
Thanks in advance for any replies.
For Static IP address assignment
Debian/Ubuntu Base Distro :- you can edit /etc/network/interfaces file, which contains information about the Network Configuration.
RedHat/CentOS Base Distro, you can edit /etc/sysconfig/network file.
If you can't find either of the files, then append the following commands to either ~/.bashrc or /etc/bash.bashrc file in your linux machine
ip link set eth1 down
ifconfig eth1 0.0.1.2 netmask 255.255.255.0
route add default gw 0.0.1.2 eth1
ip link set eth1 up
~./bashrc is user specific file and /etc/bash.bashrc is common for all users. Whenever the any user login to system, and you have added the mentioned commands in /etc/bash.bashrc file, then these commands will be executed by the system. The user won't have to execute these commands manually.
For Further Details visit:- http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html

Multiple ip addresses with different network routes on the same interface on debian [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'd like to configure a debian box with multiple ip addresses (in the same subnet) on the same physical NIC in debian, while every address should use it's own network route.
I think it won't be able using ip addr add, but is it possible using pseudo interfaces like eth0:0 ? Or does the linux TCP stack prevent this? And if it's possible, how do I bind multiple default routes to their (pseudo-)interface or ip address? will it be able using iptables roules and with which?
Aliases are not required to do this You can do this with iproute2
ip addr add <ip> dev eth0
you then add routing to a ip specific route table
ip route add subnet dev eth0 table <tableid>
ip route add default via <GATEWAY> table <tableid>
Then add a rule to match the ip so that it uses the specific table
ip rule add from any to <ip> lookup <tableid>
ip route add from <ip> to any lookup <tableid>
This can get pretty confusing because the routing is now multiple routing tables

SNAT target option in Centos [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have a remote server where I have added a new FAILOVER IP in a new interface, ETH0:0. Everything works perfectly; IP is setup. I want the traffic that is coming from ETH0:0 to use the ETH0:0 as the IP source. For example, when I send emails from my SERVER it uses The ETH0 IP which is not what I want.
So, the traffic coming from ETH0 use its IP in Source IP of The Packet,
and the traffic coming from ETH0:0 uses its IP and so on. Here is what I have tried:
iptables -t nat -A POSTROUTING -p tcp -o eth0:0 -j SNAT --to-source 51.XXX.XXX.XXX ;
Where the interface ETH0:0 Has the IP 51.XXX.XXX.XXX.
Thank you!
IP tables does not differentiate eth0:0 from eth0. In fact, eth0:0 will not work because eth0:x is an alias to the interface eth0 not a different one. Try something like this.
echo 200 ip2 >> /etc/iproute2/rt_tables
ip rule add from eth0:0 dev eth0:0 table ip2
ip route add default via <gateway_IP> dev eth1 table ip2
This will route your traffic from the same incoming interface but might not work for aliases

Changing the static IP of Beagle Bone Black USB0 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
My goal is to change the IP address of USB0.
The Beagle Bone Black run Debian.
I tryed to change /etc/network/interfaces such that default address is 192.168.7.3 instead of 192.168.7.2 as this:
iface usb0 inet static
address 192.168.7.3
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1
After running
/etc/init.d/networking restart
It was still on 192.168.7.2.
I tryed rebotting, and yet is to no avail.
I tryed to change the IP address in /boot/uboot/scripts/setup-ubuntu-armhf-3.8.13-bone30.sh, but basicly this file overwrites /etc/network/interfaces.
Still after reboot the IP is still 192.168.7.2.
Edit:
Also tryed to change the IP in:
/media/Angstrom/usr/bin/g-ether-load.sh
/media/Angstrom/etc/udev/rules.d/udhcpd.rules
Which didn't work.
Tryed to change it in:
/opt/scripts/boot/am335x_evm.sh
And now the network is unreachable:
ssh: connect to host 192.168.7.3 port 22: Network is unreachable
I was having the same problem on:
BeagleBoard.org Debian Image 2017-03-19
The issue turned out to be "connmand" (read it again, it starts with coNN, not comm). It is a horribly named program as it is difficult to research as Google assumed you spelled something wrong.
connman automatically configures wired instances for dhcp despite what is listed in /etc/network/interfaces.
Recommend either disabling it, or adding your interface to be ignored:
/etc/connman/main.conf:
NetworkInterfaceBlacklist=SoftAp0,usb0,usb1,eth0
After doing that and restarting, my static IP configured for eth0 in /etc/network/interfaces started working.

Resources