LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to set static IPV4 in linux (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-static-ipv4-in-linux-4175599223/)

Brad H 02-07-2017 06:32 PM

How to set static IPV4 in linux
 
Using Virtual Box

nano /etc/network/interfaces
auto eth0 inet static
192.168.1.39
netmask 255.255.255.0
gateway 192.168.1.1

"Cntrl-X" and "y" and "return" then reboot

in several modes, bridged, Internal network, and NAT

also have tried 10.1.2.39 in bridged mode (seems like NAT likes the 10.1 address space - not sure why yet)

the the IPV4 is not changing so far.

Looking for some insight from a more experienced user, Thank you.
Brad

frankbell 02-07-2017 08:14 PM

I have a few thoughts off the top of my head:

If you are using "bridged mode" on a network in the 192.168.x.x range, you will not be able to set a static ip address in the range of 10.x.x.x and have it work. If you select "host only" networking, the VM cannot connect to the big wide world. It can connect only to other VMs configured for "host only" on the same host.

There are some variations among distros regarding how to set a static ip. What distro are you trying to set a static ip address for?

Have you checked the VirtualBox documentation on networking?

Brad H 02-08-2017 10:37 AM

Thanks, btw - I hit resolved my mistake.

I have checked the Virtual Box Doc's. Host only is fine. I am setting up a lab with Kali and Metasploitable-2.

Additional inputs appreciated. Thanks.

r3sistance 02-08-2017 07:52 PM

I can't see a clear explanation of what the issue is?

What I think you are saying the issue is, is that the VM is still getting dynamic IPs after setting up a static IP? If that is the case then I suspect the culprit maybe dhclient, it will be some form of DHCP anyway.

What would also help is some output to show what you are seeing, what does the output of "ip addr" appear like?

Brad H 02-09-2017 11:57 AM

2: eth0: <BROADCAST ,MULTICAST , UP ,LOWER_UP> 1500 disc pfifo_fast state up group default qlen 1000
link/ether 08:00:27:f3:5a:23 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 86357sec preferred_lft 86357 sec
inet6 fe80::b891:90b7:5e9d:35c9/64 scope link
valid_lft forever preferred_lft forever
(Kali)


2: eth0: <BROADCAST ,MULTICAST , UP ,LOWER_UP> 1500 disc pfifo_fast state up group default qlen 1000
link/ether 08:00:27:92:92:ee brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 86357sec preferred_lft 86357 sec
inet6 fe80::a00:27ff:fe92:92ee/64 scope link
valid_lft forever preferred_lft forever
(Metasploitable)

NAT is the only network setting that displays IPV4. The addresses I assigned in aut0 /etc.. were 10.0.2.39 and 10.0.2.68.
The addresses I am trying to assign are 192.168.1.38 and 192.168.1.68, respectively.

Appreciate your help in getting this issue solved.

r3sistance 02-09-2017 12:06 PM

mmm missed marking solved was a mistake...

Anyways. can you confirm which distro you are using, I've been assuming it is either Debian or Ubuntu but I can't see that you have said.

Brad H 02-10-2017 10:42 AM

The first load (Kali) is Debian
The second load (Metaspoitable) is Ubuntu

thanks for engaging on this.

r3sistance 02-10-2017 12:25 PM

So I am thinking dhclient or network-manager is the likely root of your problems, network-manager runs as a service.

For dhclient you can do "ps aux | grep dhclient" to see if it is running, just remember that this will also return the grep itself. you can then kill the dhclient process in anyway.

If it is network manager then "sudo stop network-manager" will stop it. if it isn't either of these two then I am not certain what maybe causing the issue.

Brad H 02-22-2017 12:22 PM

dhclient or network-manager may have been at the root of the problem. I did however switch from Virtual Box to Vm ware and was able to set the static IP for the Debian (Kali), but not the Ubuntu. I receive a permission denied error when I go change the IP. I am apparently logged in as root user. At this point open too most suggestions.

r3sistance 02-22-2017 12:26 PM

Quote:

Originally Posted by Brad H (Post 5674614)
dhclient or network-manager may have been at the root of the problem. I did however switch from Virtual Box to Vm ware and was able to set the static IP for the Debian (Kali), but not the Ubuntu. I receive a permission denied error when I go change the IP. I am apparently logged in as root user. At this point open too most suggestions.

Where did you get the permission denied? Were you edtting a file? using the ip command? need a bit more info to help.

Brad H 02-23-2017 11:27 AM

nano /etc/network/interfaces
auto eth0 inet static
192.168.1.68
netmask 255.255.255.0
gateway 192.168.1.1

"Cntrl-X"; "y" and then "return" yields Permission denied.

thank you

r3sistance 02-23-2017 11:30 AM

try "sudo nano /etc/network/interfaces"

you need root/superuser privs to edit /etc/network/interfaces

Brad H 02-24-2017 11:34 AM

perfect - thank you


All times are GMT -5. The time now is 02:56 PM.