OpenVZ Forum


Home » General » Support » how to set subnet mask
how to set subnet mask [message #8757] Tue, 05 December 2006 15:33 Go to next message
kasarfa is currently offline  kasarfa
Messages: 1
Registered: December 2006
Junior Member
Im tyring to setup VPS with OpenVZ.

I used vzctl command.
vzctl set 101 --ipadd [IP]

and checked conf
cat /etc/sysconfig/vz-scripts/101.conf
IP_ADDRESS="[IP]"

After that, Start OpenVZ and enter.
But, Can not connect network.
Because, VE's subnet mask is not HW's.

HW's subnet mask 255.255.255.248
VE's subnet mask 255.255.255.255

I tried to change subnet mask and restart network.

vi /etc/sysconfig/network-scripts/ifcfg-venet0:0
NETMASK=255.255.255.248
#NETMASK=255.255.255.255

/etc/init.d/network restart

VE's success to connect HW.
But, after restart OpenVZ, subnet mask back to 255.255.255.255


Anyone know set subnet mask?
I could not find command in vzctl --help.

Re: how to set subnet mask [message #8772 is a reply to message #8757] Wed, 06 December 2006 07:58 Go to previous message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Hello,

I really don't know why do you need it ('cause <venet0 in VE> is directly connected to <venet on HN>), but will explain how to do it.

Step by step guide (works at least for vzctl-3.0.13):

1. Determine which template do you use for the VE in question:
# grep TEMPL /etc/vz/conf/202.conf
OSTEMPLATE="fedora-core-4-i386-default
#

So this is fedora-core-4 in my case.

2. Figure out which script runs to setup network for this template:
# grep =  /etc/vz/dists/fedora-core-4.conf
ADD_IP=redhat-add_ip.sh
DEL_IP=redhat-del_ip.sh
SET_HOSTNAME=redhat-set_hostname.sh
SET_DNS=set_dns.sh
SET_USERPASS=set_userpass.sh
SET_UGID_QUOTA=set_ugid_quota.sh
POST_CREATE=postcreate.sh
#

I can see that script redhat-add_ip.sh runs when we do --ipadd.

4. Modify script in order it to use required NETMASK:
# grep NETMASK /etc/vz/dists/scripts/redhat-add_ip.sh
NETMASK=255.255.255.255
NETMASK=255.255.255.255" > ${IFCFG_DIR}/bak/${VENET_DEV_CFG}:${ifnum} || \
# vim /etc/vz/dists/scripts/redhat-add_ip.sh
[root@white ~]# grep NETMASK /etc/vz/dists/scripts/redhat-add_ip.sh
NETMASK=255.255.255.248
NETMASK=255.255.255.248" > ${IFCFG_DIR}/bak/${VENET_DEV_CFG}:${ifnum} || \

5. Check that it works:

# vzctl start 202
Starting VE ...
VE is mounted
Setting CPU units: 1000
VE start in progress...
# vzctl enter 202
entered into VE 202
[ve]# ifconfig | grep Mask
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.248

[ve]# exit
logout

exited from VE 202
# vzctl stop 202
Stopping VE ...
VE was stopped
VE is unmounted
# /etc/init.d/vz stop
Stopping OpenVZ:                                           [  OK  ]
# /etc/init.d/vz start
Starting OpenVZ:                                           [  OK  ]
Bringing up interface venet0:                              [  OK  ]
Configuring interface venet0:                              [  OK  ]
# vzctl start 202
Starting VE ...
VE is mounted
Setting CPU units: 1000
VE start in progress...
# vzctl enter 202
entered into VE 202
[VE]# ifconfig -a | grep Mask
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.248


HTH,
Vasily.
Previous Topic: vzquota : (error) Quota on syscall for 777: No such file or directory
Next Topic: ERROR: Core::SplitDevPath: Cannot get device for
Goto Forum:
  


Current Time: Thu Oct 17 03:08:46 GMT 2024

Total time taken to generate the page: 0.05481 seconds