How to setup Proxmox with Single Public IP and share with VMs

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys how you doing today i'm going to be showing you in this video how to use proxmox with one ip and what i mean by that is sometimes when you order a dedicated server from a cloud provider they sometimes only give you one ip address or maybe you're just trying to save costs and you don't want to purchase additional ips so you want to use one static ip and not just use it for proxmox but you can also use it for a vmware like a hypervisor and then you create ip tables to allow certain ports like let's say you have three vms one's a web server one's a database server and let's just say the other one's a game server but they all can't use that same ip right because the static ip is assigned to proxmox and then you have all these vms but they don't have extra ips to assign those servers so what you can do is use iptables to allow certain traffic to like a local network to get access to that vm so i'm going to kind of show you as we go along here on how to do that i did want to show you this powerpoint of what we're going to be doing so you can see here's our internet connection come into our dedicated server at a data center or maybe it's you know at your house then you could do uh that's our public ip so you can see the hardware interface is en01 that goes to a virtual bridge which is vmbr0 and it's got that static ip that you only have that one ip address to then you can see we created another hardware bridge onto that called a vmbr1 and then we gave this public i'm sorry this local uh static ip address then within each vm that's connected to that virtual bridge we gave it these local ips you can sign any ip you want within this range but i just want to show you what i did i have three vms and i just gave it 1.50 you know 150 160 170 easy to remember and these can all tunnel through this virtual bridge to that virtual bridge and then out to the internet so that's how that works this is uh basically this dedicated box so i'll hope this showing it in a display format like this you're going to see what we're going to be doing you're basically routing all these packets out this gateway into this virtual bridge and then eventually out to this ip address out to the internet so that's how that works so let's go ahead and dive in and i'm going to show you how how to accomplish this so you can see we're at our proxmox we're going to go ahead and log in we have three vms in this server they all have local ips and what i mean by that is they all have a 192 168 10.100 address so this is like an internal lan i guess you could call it that is bridged to this virtual interface which is that is bridge to the actual network hardware interface so you can see this is our public ip here and we want to do is go ahead and go to create and we're going to create a linux bridge and we already have this created so i'm just going to show you what you need to create so you're going to want to name it vm br1 and then in the ipv4 that's where we need to type in the local now this can be any subnet practically any variation really but it needs to be a local subnet kind of like that and then we're doing the slash 24 because that's the subnet for that ip range so it's best to use my example so then you don't get confused with different subnets and having you know you just follow what i do and it's going to work so go ahead and type that in make sure auto start is on and then you hit create i'm not hitting create because you can see i already have um the vmbr one linux bridge right here and it's literally the same set of settings i just did you can see that's the subnet there so once you have that created you can go into your vm now and you also need to make sure you need to go to hardware and you go to network device here and you need to change it to the vmbr one it'll default to the zero one because that's usually what happens when you you only have one uh interface so you wanna make sure it's the vmbr one bridge there so once you have that set then you probably need to reboot your vm but sometimes you don't need to do that so once you get into your vm then um it should have no ip address because there is no dhcp server so we need to go to control panel go to network and internet network and sharing center and then change adapter settings then right click on our interface go to properties double click on ipv4 and then set this as a static ip for that same you want to be in that same subnet so you want to do that 192.168.10.whatever i just did 1.160 in this case and then you want to make sure your default gateway is that dot 100 because that's where we set that interface to so that's the gateway to get out of that bridge onto the next bridge so that's when you want to make sure that's the dot 100 there or if you do dot one it's not going to work so you want to make sure you do dot 100 the basically the same ip as you just said in the previous section that we just set up that network bridge and then the dns you just want to do google's dns or a cloud cloud dns or you know whatever whatever dns server you prefer so we can go and close that out close that out so i just did a quick ipconfig all just to make sure we are reading that ip address and we are and once you set these ips correctly you should be able to get onto the internet so i should be able to open up google right now and reach out to the internet so let's go ahead and make sure that works sorry this uh vm's a little slow because i didn't really give it a lot of resources okay so now you can see google's up and you can see i'm online and if i do what is my ip it's going to give me the ip address of that static ip that's assigned to proxmox because it's basically using that shared internet connection do that one static ip so now you're saying okay that's great i have internet at least but how do i let's say i'm hosting like right now i have x-amp on here and i'm hosting a couple websites how do i get that public ip port 80 and 443 to this vm well i'm going to show you how to do that first you need to open up your firewall on the vm and make sure you have port 80 and 443 open so if you don't have this set up you need to create a rule it's very easy you just go here go into your firewall hit new rule and this could be a web server this could be a game server so if you're hosting like a cs go server open up 27015 tcp and udp um you know it's the same process it's not just for web servers so we just hit next and let's say we need to open up port 80 and then we're going to do comma 443 because we're going to do two ports or if you had like a range like you want to do 80 through 100 or you know whatever you're trying to do you can do that um here so we're doing tcp hit next allow the connection yep all rules yep and then we're just naming http and https but like i said i'm not going to hit finish because i already have this exact rule created i'm just showing you how to create it so i'm hitting cancel because i already have it here so once you have that set up and you know your web server is working by just doing localhost here and you can see it is working it's just there's you know i don't have anything going to localhost right now but you can see apache is running on this port so it is working you know i went ahead and corrected that by just adding this rule in my htv host file which i didn't add by mistake so once i add in that in there and i restarted my apache service here and just do a simple restart now when i open up localhost it'll show you this page which is this index file here so if i just simply you know add you know demo and yes because i don't have pri right permissions in that file if i hit refresh you can see demo so that it's going to that actual file there so now that we know our web server is working locally and we have the right ports open we know it's fully working so now we've got to create some magic here what you need to do now is open up ssh into your proxmox server let's go ahead and do that and we want to create three rules so i'm going to open up putty we're going to connect to our proxmox public ip which is that's what our public ip is and then we're going to hit open and i'm going to put in the password here but you can just use putty and ssh and get to that point all right we are now ssh into our box here so go ahead and yep so we are connected and we are good so we want to do is create three rules so i mean we're really two rules i'm just adding a third one in there because i'm assuming you probably want rdp access from outside of this server correct i would think so so the first rule is going to create you can see right here iptables uh pre-routing because it's basically going to take this is your public because you only get one ip address remember that and so if someone goes to the site public ip and it's using and they're on port 80 it's going to redirect all that traffic to this destination which is that ip address we set for this box on port 80. so does that make sense so you want to copy that rule and paste it in here and then hit enter and that's going to basically take all that port 80 traffic from that public ip to this local ip so that's as simple as that you guys and you can do that for anything so like let's say um you know you want to do it for um your cs you're running a csgo server so i just basically uh copy that sorry i actually hit the wrong key so copy that and then uh you know i believe csgo uses 27015 so you want to make sure you change it there and then whatever server on your that local network you created and then change it here so let's say we had another server on that network and we said it i a static ip2 161 then we would set it for that that port that port and then you would create that rule and then i'm copying this and pasting it again because i think cs go also requires udp so it's as simple as that so you would just change it from tcp to udp and then paste these two rules in your list and there you have it you have your uh firewall rule set up now i'm not creating this rule because i already have it created so i don't really need to recreate it but i'm just showing you how to uh create those rules once you have those rules open you can open up any web browser not from this server but like your actual computer and go to your public stack ip and there you have it it's open and working so i'll show you another example here is um let's go to this server actually this server is running a cs go server so let's go and log in alright so we are logged in so this is another server that's sharing that same public static ip so you can see once i do another ipconfig slash all you can see i set this ip for 10.150. so this is where our cs go server is at so i would basically change this to 50 here and 50. and then i would copy these rules and paste them into our ssh connection and create those iptable rules now once you are done creating those rules let's say you create a rule and you're like crap i didn't mean to create that rule or maybe you duplicated the rule and you just want to delete it or maybe you don't want it anymore and you want to delete it i'm going to show you how to do that and how to list the roles as well all right so once we are in our ssh tunnel we're going to go ahead and do some commands to list all of our ip table rules so you want to type in iptables space tag t space not spit attack l tact line tac number and hit enter so this is listing all of our iptaper rules that we have set up on this proxmox server so you can see the target you can see if it's tcp or udp you can see its source anywhere which is good the destination and then the final destination and the protocol type and the ipa and then you see the port number and the ip address at the end you can see those are all those local ips that we set up so let's say we need to delete one of these because you messed it up or whatever so you can just type in iptables talk t not talk capital d and then you want to do pre routing i believe and then you just type in the number so you can see uh number nine uh let's say we just want to delete that because we messed up we didn't want to do udp or the wrong port or whatever so we'll just type in nine hit enter it deleted that rule so if i do line numbers again you can see number nine is now gone now before you exit because you think you're all done you actually want to do iptables tack save and it's going to save all the rules to the server so now you can safely exit out of the ssh tunnel and you're all done so there you guys have it that's how you can have one public static ip two proxmox and then within proxmox you can have three vms uh with local ips and still be able to utilize them and still have internet connection and you can you can tell what ports to open to what vm uh it's pretty cool using ip tables it's pretty advanced you
Info
Channel: GreyTech
Views: 9,580
Rating: 4.7935486 out of 5
Keywords: How to setup Proxmox with Single Public IP and share with VMs
Id: Q5l7VH6b5r4
Channel Id: undefined
Length: 16min 10sec (970 seconds)
Published: Sat Mar 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.