Tech Junkie Blog - Real World Tutorials, Happy Coding!: Networking: Configure A Static IP in Linux On VitrualBox On A Bridge Network

Monday, June 7, 2021

Networking: Configure A Static IP in Linux On VitrualBox On A Bridge Network

 In the previous post we configured a DNS server, in this post we are going to assign a static IP to that server so that we don't get a new IP everytime we reboot the server.

First let's check our VirtualBox Adapter IP settings

1. Make sure your VM is set to the Bridge Network setting




Now turn on the VM machine and type ifconfig to the the adapter name

First let's get our network information with the command ifconfig 




Make a note of the ip address of the machine which is 192.168.0.14 in my machine, yours will be different.

Here are the steps to assign a static IP to a server in CentOS:

1. If you have a /etc/sysconfig/nework file delete with the rm command

2. Now edit the adapter file by typing in vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 with the following information


There are three settings you have to mindful of first it's the BOOTPROTO option make sure it's using dhcp, I know it's counter intuitive but you want the system to do the heavy lifting for you.  The next option is the ONBOOT option make sure you set it to "yes" because you want to boot up the adapter on boot.  Finally you want to assign a static IP to the machine.  It's important that you assign an IP that would be valid for your network.  

Now you can reboot and restart your network to your hearts content and you will be assign the same static IP.  In the next post we will revisit the DNS settings and make sure everything still works!

And that's how you assign a static IP to CentOS in Linux.  You will see that the DNS is broken currently because it's being configured to use dynamic IP.  In the next post we are going to change the DNS server to use the static IP that we've just configured.

1 comment:

  1. I’d really like to appreciate the efforts you get with writing this post. Thanks for sharing.
    CCNA classes in Bangalore

    ReplyDelete

Search This Blog