Install go environment
There are two ways to install
To install iptables-web, you need to install the go environment first
1. Use yum source installation
yum -y update
yum -y install go
Check installed version
go version
Of course, this is installed according to the yum source when there is no requirement for the version of go. However, some yum sources do not have go installation packages. If you do not want to replace the yum source, you can use the second method.
2. Use the Go installation package to install
(1) Download the installation package
wget -c https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz
(2) Unzip
After decompressing the source package, put it directly into the /opt/ directory, no need to make && make install again to install, it works out of the box
tar -C /opt/ -zxvf go1.11.5.linux-amd64.tar.gz
(3) Add system environment variables
1. Create the file
vim /etc/profile.d/go.sh
Add to the opened file
export PATH=$PATH:/opt/go/bin
Make the file just created take effect
source /etc/profile.d/go.sh
(4) Set the GPOPATH directory
The GOPATH environment variable specifies a directory, which contains all our source code, and is the working directory.
The code we write can be placed under this directory.
create working directory
mkdir -p ~/home/go/
Add this directory to GOPATH
as above, you need to create a file first
vim /etc/profile.d/gopath.sh
export GOPATH=/home/go/
Enter GOPATH in the file to point to the specific location
Make the file just created take effect
source /etc/profile.d/gopath.sh
Verify that the GOPATH environment variable is added successfully
echo $GOPATH
If the output /home/go is successful
The above basic Go environment is installed successfully. We can write a small program to run it to see if it can be executed successfully:
Create a new applet helloworld.go in the /home/user/go directory
vim helloword.go
Enter the following program in the file:
package main
import (
"fmt"
)
func main() {
fmt.Println( "Hello world!" )
}
execute program
go run helloworld.go
If the following output appears, our Go installation is successful
Second, install the iptables-web management interface
1. Docker deployment and installation
Deploy in the form of docker and pay attention to add two parameters –privileged=true, –net=host runs in privileged mode and can manage host iptables rules
docker run -d \
--name iptables-web \
--privileged=true \
--net=host \
-e "IPT_WEB_USERNAME=admin" \
-e "IPT_WEB_PASSWORD=admin" \
-e "IPT_WEB_ADDRESS=:10001" \
-p 10001:10001 \
pretty66/iptables-web:1.1.1
IPT_WEB_USERNAME: web authentication user name, default: admin
IPT_WEB_PASSWORD: web authentication password, default: admin
IPT_WEB_ADDRESS: program monitoring address, default: 10001
2. Install directly
git clone https://github.com/github-ydt/iptable-web.git
cd iptables-web
make
# 直接运行
./iptables-server -a :10001 -u admin -p admin
# 后台运行
nohup ./iptables-server -a :10001 -u admin -p admin > /dev/null 2>&1 &