Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  25] [ 0]  / answers: 1 / hits: 73349  / 1 Year ago, wed, april 19, 2023, 11:44:43

I modify dhcp to static in /etc/network/interfaces (like below).



# The primary network interface
auto eth0
iface eth0 inet static
netmask 255.255.0.0
address 10.10.130.128
gateway 10.10.1.1


Then restart the interface.



$ sudo ifdown eth0; sudo ifup eth0
...
$ ifconfig
eth0 Link encap:Ethernet
inet addr:10.10.130.128 Bcast:10.10.255.255 Mask:255.255.0.0


So the new address kicks in.



But DHCP is still there?



$ ps aux | grep dhc
root ... dhclient3 -e IF_METRIC=100 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -1 eth0


Is that normal? If not, how to restart interface in static IP while stop DHCP at the same time?



Thanks a lot.


More From » networking

 Answers
4

  1. You first have to shutdown the interface (in dhcp mode) sudo ifdown eth0

  2. Then edit the config nano /etc/network/interfaces



    # The primary network interface
    auto eth0
    iface eth0 inet static
    netmask 255.255.0.0
    address 10.10.130.128
    gateway 10.10.1.1

  3. Bring the interface back up sudo ifup eth0




Otherwise dhclient doesn't correctly shuts down,


[#25501] Wednesday, April 19, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rowbris

Total Points: 419
Total Questions: 122
Total Answers: 101

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;