관리 메뉴

bright jazz music

proxmox NAT처리. (추가 아이피를 할당하지 않고 사용하기 위해) 본문

Projects/proxmox

proxmox NAT처리. (추가 아이피를 할당하지 않고 사용하기 위해)

bright jazz music 2024. 4. 11. 10:41

 

- vm100번에는 10.10.10.100/24 아이피가 할당돼 있다.

 

- vm101번에는 10.10.10.101/24 아이피가 할당돼 있다.

 

 

 

 

 

vmbr0은 호스트의 네트워크 브릿지이다. 물리 랜카드라고 볼 수 있다.

 

vmbr1은 10번대 아이피를 가지고 있는 vm들이 사용하는 논리 브릿지이다. 가상 랜카드라고 볼 수 있다.

 

 

 

 

auto lo
iface lo inet loopback

iface ens3f0 inet manual


auto vmbr0
iface vmbr0 inet static
		#호스트머신의 아이피,게이트웨이, 네트워크 인터페이스 카드
        address 192.168.101.27/24
        gateway 192.168.101.1
        bridge-ports ens3f0
        bridge-stp off
        bridge-fd 0

        post-up echo 1 > /proc/sys/net/ipv4/ip_forward

        post-up iptables -t nat -A PREROUTING -p tcp --dport 5022 -j DNAT --to-destination 10.10.10.100:22
        post-up iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 22 -j ACCEPT
        post-down iptables -t nat -D PREROUTING -p tcp --dport 5022 -j DNAT --to-destination 10.10.10.100:22
        post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 22 -j ACCEPT

        post-up iptables -t nat -A PREROUTING -p tcp --dport 5122 -j DNAT --to-destination 10.10.10.101:22
        post-up iptables -A FORWARD -p tcp -d 10.10.10.101 --dport 22 -j ACCEPT
        post-down iptables -t nat -D PREROUTING -p tcp --dport 5022 -j DNAT --to-destination 10.10.10.101:22
        post-down iptables -D FORWARD -p tcp -d 10.10.10.101 --dport 22 -j ACCEPT



auto vmbr1
iface vmbr1 inet static
        address 10.10.10.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

        post-up echo 1 > /proc/sys/net/ipv4/ip_forward
        post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE






iface ens3f1 inet manual

iface ens3f2 inet manual

iface ens3f3 inet manual

iface enp3s0f0 inet manual

iface enp3s0f1 inet manual

iface ens1f0 inet manual

iface ens1f1 inet manual


"/etc/network/interfaces" 60 lines, 1574 bytes

 

 

호스트에서 ip addr 명령어를 쳐보면 아래와 같이 설정된 걸 볼 수 있다.

:~# ip addr | grep inet
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host noprefixroute
    inet 192.168.101.27/24 scope global vmbr0
    inet6 fe80::1efd:8ff:fe71:492c/64 scope link
    inet 10.10.10.1/24 scope global vmbr1
    inet6 fe80::6462:e7ff:fedf:8d7b/64 scope link

 

 

만약 ip addr 명령어 입력 시 NIC가 down 돼 있다면 아래와 같이 켜주자

 

ip link set <NIC명> up 

 

예시)  ip link set enf3f0 up 

'Projects > proxmox' 카테고리의 다른 글

VM의 루트 볼륨을 추가(증대)하기  (0) 2023.04.21
1. 개발서버 구축  (0) 2023.03.30
Comments