Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I set up a Virtual Machine with windows (using VMPlayer), I set the Network Connection properties from the VM settings from NAT to bridged. Then I proceed to set the following IP Properties in the OS (see image below) so that the Virtual Windows OS becomes part of my network.

How do I set the same IP Properties on a Linux machine (I use CentOS) using terminal? If its any file that needs to be edited please let me know which. I wish to set up the virtual Linux machine similar to how my Virtual Windows machines are set up.

enter image description here

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

The easiest way to edit network configuration from a shell on CentOS is to use the tool /usr/sbin/system-config-network-tui. You could also use /usr/sbin/system-config-network-cmd if you know the exact setting names.

Otherwise, you have to edit the files /etc/sysconfig/network for the HOSTNAME, and /etc/sysconfig/network-scripts/ifcfg-eth0 for eth0 configuration. But you need to know what the values should be such BOOTPROTO=static, or dhcp for dhcp.

share|improve this answer
    
@Kieth I found the file if-cfg-lo at /etc/sysconfig/network-scripts; woint simply editing this file help me set the above settings? –  Thomas May 21 '11 at 16:36
    
That one's only for loopback. Each interface has its own little config. –  Keith May 21 '11 at 19:28
    
Thanks. Took some time for me to figure this out but now that I have, its marked resolved. –  Thomas Jun 12 '11 at 13:50
add comment

On any UNIX system, you can find out which commands and/or shell scripts are used to set the network, by tracing through the sequence that is run by init when the system is started. On just about every flavor of UNIX the config is stored somewhere in /etc.

On BSD heritage systems the actual file and directory names will be different than on Linux and other System V heritage systems, but they will always have rc in the name. Look in those directories, or files and figure out where the network startup scripts are stored.

I've used this tactic successfully on everything from AIX to Caldera Linux to OpenBSD.

share|improve this answer
add comment

The address and routing information can be setup using ip. The DNS is set in the file /etc/resolv.conf.

ip addr add 172.16.5.23
ip route add 172.16.0.0/16 via 172.16.1.1

echo -e "nameserver 172.16.1.10\nnameserver 172.16.1.250" > /etc/resolv.conf
share|improve this answer
    
@Shawn J. Goff What about the Subnet Mask? –  Thomas May 16 '11 at 4:45
1  
/16 is shorthand for netmask 255.255.0.0 -- see en.wikipedia.org/wiki/CIDR_notation –  Shadur May 16 '11 at 6:49
1  
However, the commands Shawn shows here will only change the settings until you restart the system. Unfortunately, redhat and CentOS seem to be big believers in not allowing its users to see the system innards -- centos.org/docs/5/html/5.2/Deployment_Guide/… doesn't say word frickin' one about the config file syntax or even where said config file is kept. Fail. –  Shadur May 16 '11 at 6:56
    
What? I need the IP settings to stick inspite of a restart. How do I do that? –  Thomas May 16 '11 at 7:00
    
@Thomas: Try echoing that to /etc/resolv.conf.head instead. –  Reid May 17 '11 at 0:20
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.