Set static IP to Linux VM
If you are decided to not use DHCP to obtain IP dynamically for your linux box, you can set the IP manually as below.
Edit respecting ifcfg-eth* file of your network card and insert following entries in the file:
for network card eth0:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
NETWORK=10.8.227.0
NETMASK=255.255.255.192
IPADDR=10.8.227.50
DNS1=10.8.224.13
GATEWAY=10.8.227.62
IPV6INIT=no
USERCTL=no
Edit respecting ifcfg-eth* file of your network card and insert following entries in the file:
for network card eth0:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
NETWORK=10.8.227.0
NETMASK=255.255.255.192
IPADDR=10.8.227.50
DNS1=10.8.224.13
GATEWAY=10.8.227.62
IPV6INIT=no
USERCTL=no
And replace you IP, netmask, gateway and dns(if any) with your addresses.
Reactive your network card or restart you network service:
# ifdown eth0
# ifup eth0
or
/etc/init.d/network restart
There you can see your new network settings and try t ping your gateway to make sure of connection:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:50:56:B7:3B:F7
inet addr:10.8.227.50 Bcast:10.8.227.63 Mask:255.255.255.192
inet6 addr: fe80::250:56ff:feb7:3bf7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9621 errors:0 dropped:0 overruns:0 frame:0
TX packets:268 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:659779 (644.3 KiB) TX bytes:45866 (44.7 KiB)
Comments
Post a Comment