來源: [Linux][Ubuntu] Ubuntu 16.04 安裝LAMP PHP7 , Apache2 , MaraiDB « 老人的網路筆記
Category Archives: Linux
ip_forward sample
# clean all rules iptables -F iptables -t nat -F iptables -X iptables -Z #default chain iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT iptables -t nat -P PREROUTING ACCEPT iptables -t nat -P OUTPUT ACCEPT iptables -t nat -P POSTROUTING ACCEPT iptables -A INPUT -s 10.0.0.0/8 -p tcp --dport 22 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT #modify rule below this line iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.140.0.3:80 iptables -t nat -A PREROUTING -p tcp --dport 3389 -j DNAT --to-destination 10.140.0.3:3389 iptables -t nat -A POSTROUTING -j MASQUERADE iptables -L -n -t nat
编译linux内核前用make menuconfig设置时 Unable to find the ncurses libraries的解决办法
我们在更新CentOS或者Ubuntu的内核时,执行make menuconfig可能看如这样的错误:
*** Unable to find the ncurses libraries or the
*** required header files.
*** ‘make menuconfig’ requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
根据错误报告是缺少Ncurses库,需要安装该库(Ncurses 提供字符终端处理库,包括面板和菜单)
解决办法如下:
CentOS:
yum install -y ncurses-devel
Ubuntu:
sudo apt-get install ncurses-dev
Ubuntu Missing add-apt-repository command
apt-get install software-properties-common python-software-properties
ubuntu不能正常使用make menuconfig的解决方案
so easy
sudo apt-get install build-essential
sudo apt-get install libncurses5
sudo apt-get install libncurses5-dev
happy
当然有的时候在执行以上命令的时候会出错,提示要更新“软件列表”,OK,乖乖的先更新再执行以上命令吧。
更新命令
sudo apt-get update
万能的apt-get,
Install Smokeping on Ubuntu 14.04 – Oliver Marshall
I’ve recently being doing some work to set up LibreNMS to monitor our vast swath of internal switches and systems.
How To Fix 504 Gateway Time-out on Nginx – idroot
This tutorial shows you how to fix 504 gateway Timeout on Nginx
Linux开启SSH登录email通知
Linux服务器通常需要远程登录访问,尤其是当服务器或VPS还允许root直接登录时,应该为SSH登录成功配置一个自动的email提醒。
sendmail直接发送的话很可能会发送到垃圾邮箱里,需要把地址加入到白名单。
把下面的admin@hackhp.com更改为你要接收登录通知的电子邮件地址。
CentOS
vim ~/.bash_profile
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' admin@hackhp.com
Ubuntu/Debian
vim ~/.bashrc
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' admin@hackhp.com
如果不想接收到邮箱,只想重定向到一个文件的话。
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' >>/root/login.txt
denyhosts 設定檔簡易說明
Step One—Install Deny Hosts
We need to use a repository to install Deny Hosts on CentOS.
sudo rpm -Uvh http://mirror.metrocast.net/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
sudo yum install denyhosts
Once the program has finished downloading to the VPS, denyhosts is installed and configured.
yum install denyhosts
http://blogger.liaohaha.tw/2012/02/denyhosts.html
使用 NetworkManager 設定網路
從 RHEL7/CentOS7 開始,NetworkManager 已經過更好的改良,使用 NetworkManager 服務可以一次設定好網路組態與DNS,而不用再一個一個檔案修改。
nmcli 為 NetworkManager 主要的設定指令,包含豐富的參數選項,更容易調整網路位置,以往在同一張網卡綁定多個 IP 時需要設定多個網路卡網態,現在也需要使用一行指令即可隨意增加或修改。
開始設定
IP 與閘道
- NIC Name: eno16780032
- Tag Name: eth0
- Type: ethernet
- 1st IPv4 IP: 192.168.1.192/24
- 2nd IPv4 IP: 192.168.1.25/24
- IPv4 Default Getway: 192.168.1.1
1
2
|
root # nmcli connection add ifname eno16780032 con-name eth0 type ethernet ip4 192.168.1.192/24 gw4 192.168.1.1
root # nmcli connection modify eth0 +ipv4.addresses 192.168.1.25/24
|
- ifname:網路卡名稱(Deivce 編號)
- con-name:網路卡別名
- type:網路型態
- ip4:IPv4 位置,需加上網路區段
- gw4:IPv4 閘道位置
設定 DNS
- DNS1: 192.168.1.191
- DNS1: 8.8.8.8
1
2
|
root # nmcli connection modify eth0 ipv4.dns 192.168.1.191
root # nmcli connection modify eth0 +ipv4.dns 8.8.8.8
|
- ipv4.dns:設定第 1 組 DNS 位置
- +ipv4.dns:設定第 2 組 DNS 位置(若有多個會累加)
Start eth0
1
|
root # nmcli connection up eth0
|
檢查設定
查看 IP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
root # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16780032: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:50:56:bc:5f:90 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.192/24 brd 192.168.1.255 scope global eno16780032
valid_lft forever preferred_lft forever
inet 192.168.1.25/24 brd 192.168.1.255 scope global secondary eno16780032
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:febc:5f90/64 scope link
valid_lft forever preferred_lft forever
|
查看 Routing table
1
2
3
4
5
|
root # route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 1024 0 0 eno16780032
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eno16780032
|
查看 DNS
1
2
3
4
5
|
root # cat /etc/resolv.conf
# Generated by NetworkManager
search intra.twlab.net
nameserver 192.168.1.191
nameserver 8.8.8.8
|