1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

一つのIPでproxmox上の仮想OSからインターネットに出る(iptables)

Last updated at Posted at 2014-04-16

proxmox(vmbr0:0)の設定

/etc/network/interfaces
+ auto vmbr0:0
+ iface vmbr0:0 inet static
+         address 192.168.101.1
+         netmask 255.255.255.0

※ 2021年現在は vmbr0:0ではなく vmbr0をもう1セット書くのが良いみたい。NetworkConfiguration - Debian Wiki

proxmox上のOpenVz設定

  • ip: 192.168.101.2/24

設定

apt-get install -y iptables-persistent
POSTROUTING設定をする。
iptables -t nat -A POSTROUTING -s 192.168.101.0/24 -o vmbr0 -j MASQUERADE
再起動後も有効にする
/etc/init.d/iptables-persistent save
Saving rules... IPv4... IPv6...done.
  • /etc/iptables/rules.v4 に保存される。
POSTROUTING設定を削除する場合
iptables -t nat -F

動作確認

コンテナ内からネットに出られることを確認。
# vzctl enter 100
[root@vz100 /]# ping google.co.jp
pingが通ること。
[root@vz100 /]# yum install -y nkf
インストールができること
[root@vz100 /]# exit
proxmoxからコンテナにsshできることを確認。
# ssh root@192.168.101.2

proxmox 4 の場合

apt-get install -y iptables-persistent
POSTROUTING設定をする。
iptables -t nat -A POSTROUTING -s 192.168.101.0/24 -o vmbr0 -j MASQUERADE

iptables -t nat -L
再起動後も有効にする
/usr/share/netfilter-persistent/plugins.d/15-ip4tables save
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?