Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-07-2017, 06:32 PM
|
#1
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Rep: 
|
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
|
|
|
02-07-2017, 08:14 PM
|
#2
|
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 20,014
|
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?
|
|
1 members found this post helpful.
|
02-08-2017, 10:37 AM
|
#3
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Original Poster
Rep: 
|
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.
|
|
|
02-08-2017, 07:52 PM
|
#4
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
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?
|
|
|
02-09-2017, 11:57 AM
|
#5
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Original Poster
Rep: 
|
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.
|
|
|
02-09-2017, 12:06 PM
|
#6
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
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.
Last edited by r3sistance; 02-09-2017 at 12:07 PM.
|
|
|
02-10-2017, 10:42 AM
|
#7
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Original Poster
Rep: 
|
The first load (Kali) is Debian
The second load (Metaspoitable) is Ubuntu
thanks for engaging on this.
|
|
|
02-10-2017, 12:25 PM
|
#8
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
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.
|
|
|
02-22-2017, 12:22 PM
|
#9
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Original Poster
Rep: 
|
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.
|
|
|
02-22-2017, 12:26 PM
|
#10
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
Quote:
Originally Posted by Brad H
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.
|
|
|
02-23-2017, 11:27 AM
|
#11
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Original Poster
Rep: 
|
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
|
|
|
02-23-2017, 11:30 AM
|
#12
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
try "sudo nano /etc/network/interfaces"
you need root/superuser privs to edit /etc/network/interfaces
|
|
|
02-24-2017, 11:34 AM
|
#13
|
LQ Newbie
Registered: Feb 2017
Posts: 7
Original Poster
Rep: 
|
perfect - thank you
|
|
|
All times are GMT -5. The time now is 11:20 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|