In my /etc/network/interfaces.d/eth0
I have set:
auto eth0
iface eth0 inet static
address 10.0.0.25
netmask 255.255.255.0
gateway 10.0.0.1
dns-nameservers 8.8.8.8 8.8.4.4
Which shall assign my local machine a static IP from the local network on my interface eth0
.
After restarting the network with service networking restart
I still have my old IP (192.168.178.25) assigned when checking with ifconfig
eth0 Link encap:Ethernet HWaddr 09:c5:e3:f1:a3:05
inet addr:192.168.178.25 Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: XXXX::XXXX:XXXX:XXXX:XXXX/64 Scope:Link
inet6 addr: XXXX:XXXX:XXXX:X:XXXX:XXXX:XXXX:XXXX/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21005449 errors:0 dropped:2187 overruns:0 frame:0
TX packets:19834119 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15429610791 (15.4 GB) TX bytes:12129886014 (12.1 GB)
Interrupt:114
Now to the funny part:
When pinging this machine on my local network, I get responses from either 10.0.0.25 or 192.168.178.25:
PING 10.0.0.25 (10.0.0.25) 56(84) bytes of data.
64 bytes from 10.0.0.25: icmp_seq=1 ttl=64 time=0.220 ms
64 bytes from 10.0.0.25: icmp_seq=2 ttl=64 time=0.189 ms
64 bytes from 10.0.0.25: icmp_seq=3 ttl=64 time=0.196 ms
--- 10.0.0.25 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.189/0.201/0.220/0.021 ms
PING 192.168.178.25 (192.168.178.25) 56(84) bytes of data.
64 bytes from 192.168.178.25: icmp_seq=1 ttl=64 time=0.189 ms
64 bytes from 192.168.178.25: icmp_seq=2 ttl=64 time=0.191 ms
64 bytes from 192.168.178.25: icmp_seq=3 ttl=64 time=0.191 ms
--- 192.168.178.25 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.189/0.190/0.191/0.011 ms
(As the gateway also has changed, I now get a different outside ip address than before while still routing the traffic via my old (gateway and) outside ip!?)
What safe way is there to get the newly assigned ip solely without rebooting the machine and by only using ssh and not loosing access?
Some people state ifdown eth0; ifup eth0
is the way to go, but some say this messes up the entire machines connection when run on ssh.