Cách Port Forward khi chia vps trên dedicated server chạy Ubuntu

ngocanhnguyenan

New member
..

## Cách chuyển tiếp khi chia VPS trên máy chủ chuyên dụng chạy Ubuntu

Chuyển tiếp cổng là một kỹ thuật mạng cho phép bạn truy cập các dịch vụ trên máy chủ từ xa từ mạng cục bộ.Điều này có thể hữu ích để lưu trữ một trang web hoặc dịch vụ khác trên VPS không thể truy cập trực tiếp từ Internet.

Để chuyển tiếp trên một VP đang chạy Ubuntu, bạn sẽ cần sử dụng các bước sau:

1. ** Đăng nhập vào VPS của bạn. ** Bạn có thể làm điều này bằng SSH hoặc kết nối máy tính để bàn từ xa.
2. ** Mở thiết bị đầu cuối. ** Bạn có thể làm điều này bằng cách nhấn `ctrl+alt+t`.
3. ** Cài đặt gói `net-tools`. ** Gói này chứa các công cụ bạn cần để quản lý giao diện mạng của mình.

`` `
sudo apt-get cài đặt công cụ net
`` `

4. ** Liệt kê các giao diện mạng của bạn. ** Bạn có thể làm điều này bằng cách chạy lệnh sau:

`` `
IP addr show
`` `

Điều này sẽ xuất ra một danh sách tất cả các giao diện mạng của bạn, bao gồm tên và địa chỉ IP của họ.

5. ** Tìm tên của giao diện mà bạn muốn chuyển tiếp các cổng trên. ** Đây thường là giao diện được kết nối với mạng cục bộ của bạn.

6. ** Tạo quy tắc chuyển tiếp cổng. ** Bạn có thể làm điều này bằng cách chạy lệnh sau:

`` `
sudo iptables -t nat -a prerouting -i <tên giao diện> -p tcp -dort <port number> -j dnat - -estination <địa chỉ IP công khai>: <số cổng>
`` `

Thay thế các giá trị sau trong lệnh:

* `<tên giao diện>` với tên của giao diện mà bạn muốn chuyển tiếp các cổng trên.
* `<Số cổng>` với số cổng mà bạn muốn chuyển tiếp.
* `<Địa chỉ IP công cộng>` với địa chỉ IP công khai của VPS của bạn.
* `<Số cổng>` với số cổng của dịch vụ mà bạn đang lưu trữ trên VPS của mình.

7. ** Lưu quy tắc chuyển tiếp cổng. ** Bạn có thể thực hiện điều này bằng cách chạy lệnh sau:

`` `
sudo iptables-save
`` `

8. ** Bật quy tắc chuyển tiếp cổng. ** Bạn có thể thực hiện điều này bằng cách chạy lệnh sau:

`` `
Dịch vụ sudo iptables khởi động lại
`` `

9. ** Kiểm tra quy tắc chuyển tiếp cổng. ** Bạn có thể làm điều này bằng cách sử dụng trình duyệt web để truy cập dịch vụ mà bạn đang lưu trữ trên VPS của mình.

Nếu bạn có thể truy cập dịch vụ, thì quy tắc chuyển tiếp cổng đã được tạo thành công.

## hashtags

* #ubuntu
* #Vps
* Máy chủ #Dedifyed
* #Cổng chuyển tiếp
* #NetWorking
=======================================
#ubuntu #Vps #Dedicated Server #Port Forwarding #NetWorking

## How to Port Forward When Dividing VPS on Dedicated Server Runs Ubuntu

Port forwarding is a networking technique that allows you to access services on a remote server from a local network. This can be useful for hosting a website or other service on a VPS that is not directly accessible from the internet.

To port forward on a VPS that is running Ubuntu, you will need to use the following steps:

1. **Log in to your VPS.** You can do this using SSH or a remote desktop connection.
2. **Open the terminal.** You can do this by pressing `Ctrl+Alt+T`.
3. **Install the `net-tools` package.** This package contains the tools you need to manage your network interfaces.

```
sudo apt-get install net-tools
```

4. **List your network interfaces.** You can do this by running the following command:

```
ip addr show
```

This will output a list of all of your network interfaces, including their names and IP addresses.

5. **Find the name of the interface that you want to forward ports on.** This is usually the interface that is connected to your local network.

6. **Create a port forwarding rule.** You can do this by running the following command:

```
sudo iptables -t nat -A PREROUTING -i <interface name> -p tcp --dport <port number> -j DNAT --to-destination <public IP address>:<port number>
```

Replace the following values in the command:

* `<interface name>` with the name of the interface that you want to forward ports on.
* `<port number>` with the port number that you want to forward.
* `<public IP address>` with the public IP address of your VPS.
* `<port number>` with the port number of the service that you are hosting on your VPS.

7. **Save the port forwarding rule.** You can do this by running the following command:

```
sudo iptables-save
```

8. **Enable the port forwarding rule.** You can do this by running the following command:

```
sudo service iptables restart
```

9. **Test the port forwarding rule.** You can do this by using a web browser to access the service that you are hosting on your VPS.

If you are able to access the service, then the port forwarding rule has been successfully created.

## Hashtags

* #ubuntu
* #Vps
* #Dedicated Server
* #Port Forwarding
* #NetWorking
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock