New IP address does not persist after restart [closed] - linux

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

Related

bug with "hostname -i" [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 2 years ago.
Improve this question
when i type :
hostname -i
my return is returning something really strange (for security it is not the real ip)
2001:db8:1f89::%et0 2001:db8:1f89::%eth1 2001:db8:1f89::%eth2 192.168.1.1 192.168.1.2
i have the same configuration on many other machine
and i dont fint why its is not returning the right thing, it should be only the ip set in the /etc/hosts file.
192.168.1.1
i tried :
hostnamectl
changing the /etc/hosts file
checked the /etc/host.conf
nmcli hostname
/etc/sysconfig/network
/etc/hostname
reboot
nothing point to this
regards,
Using the -i option display the network addresses of the host name, including the loopback interface and IPv6 link-local addresses.
Using the -I option display all network addresses of the host excluding loopback interface and IPv6 link-local addresses.
Sometime reading the man could be enough. Just type man hostname :)

/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.

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

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.

How to send requests via virtual interface [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 9 years ago.
Improve this question
I have created a virtual interface using
ifconfig eth0:1 192.168.50.10 netmask 255.255.255.0 up
Now I'm sending a request to a server via the virtual interface using curl:
curl --interface 192.168.50.10 http://192.168.50.1:8080/myhostedapp
This works fine and my app shows the source ip as 192.168.50.10, but if the server is on a different subnet, and reachable from the physical interface (eth0), the connection times out.
So this works (via the physical interface):
curl http://10.10.50.1:8080/myhostedapp.
But this fails:
curl --interface 192.168.50.10 http://10.10.50.1:8080/myhostedapp.
For 10.10.50.1 to reach 192.168.50.10, I added it to the route table.
What do I need to configure so that 10.10.50.1 is reachable from 192.168.50.10?
You have to set iptunnel you can see this link it would make it more clear, one more thing when you added route you added the route with a gateway.
https://unix.stackexchange.com/questions/44065/linux-networking-routing-to-virtual-ip-addresses-from-a-different-subnet
Thanks & Regards,
Alok Thaker
First off, you shouldn't use ifconfig anymore. It is unmaintained since 10 years or so and known to have some issues, esp. regarding "virtual interfaces".
Better use ip from the iproute2 package.
See also this articles about ifconfig vs. ip and what the replacement commands look like:
Deprecated Linux networking commands and their replacements
iproute2: Life after ifconfig
ifconfig sucks
Now regarding your issue: what does your routing table look like? Please provide the output of ip address show eth0 and ip route show. I suspect your routing table to be the culprit.

Resources