LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 02-07-2017, 06:32 PM   #1
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Rep: Reputation: Disabled
Question 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
 
Old 02-07-2017, 08:14 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,534
Blog Entries: 28

Rep: Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204Reputation: 6204
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.
Old 02-08-2017, 10:37 AM   #3
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-08-2017, 07:52 PM   #4
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
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?
 
Old 02-09-2017, 11:57 AM   #5
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-09-2017, 12:06 PM   #6
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
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.
 
Old 02-10-2017, 10:42 AM   #7
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
The first load (Kali) is Debian
The second load (Metaspoitable) is Ubuntu

thanks for engaging on this.
 
Old 02-10-2017, 12:25 PM   #8
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
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.
 
Old 02-22-2017, 12:22 PM   #9
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-22-2017, 12:26 PM   #10
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
Originally Posted by Brad H View Post
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.
 
Old 02-23-2017, 11:27 AM   #11
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-23-2017, 11:30 AM   #12
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
try "sudo nano /etc/network/interfaces"

you need root/superuser privs to edit /etc/network/interfaces
 
Old 02-24-2017, 11:34 AM   #13
Brad H
LQ Newbie
 
Registered: Feb 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
perfect - thank you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Beagleboard Black static IPv4 connman difficulties rtmistler Linux - Embedded & Single-board computer 2 01-15-2014 07:22 AM
IPv4 static ip prefix problem happyg13 Fedora 2 10-23-2006 02:17 PM
static ipv4 linuxtesting2 Solaris / OpenSolaris 2 09-02-2006 10:31 AM
LFS livecd 6.1.1-3 eth0 setup (static ipv4) gregben Linux From Scratch 1 02-14-2006 07:20 AM
How do you set up a static IPv4-in-IPv6 tunnel? daveman Linux - Networking 1 11-16-2004 02:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration