Disclaimer: I am not very good at unix/linux! I am not suggesting this is the best way to do it but this is the way I did it!
I followed the instruction on the Ubuntu help site (the version is old, but the instructions still work).
- Open the interfaces file - sudo vi /etc/network/interfaces
- Add an entry for your interface using the below example. "address" is the address you want your server to have, "gateway" is the IP address of your router.
auto eth0 iface eth0 inet static address 10.0.0.100 netmask 255.255.255.0 gateway 10.0.0.1
- Activate the interface - sudo ifup eth0
- You now have to assign a nameserver (DNS) - sudo vi /etc/resolv.conf
- Add a nameserver(s) - e.g nameserver 8.8.8.8
- Open the following file - sudo vi /etc/resolvconf/resolv.conf.d/base
- Add a nameserver(s) - e.g nameserver 8.8.8.8
- Restart resolvconf - sudo resolvconf -u
And that's it! Your server now has a static IP that is persistent across reboots.
No comments:
Post a Comment