Category Archives: Linux networking

Restarting network (via systemctl): Job for network.service canceled

service network restart
Restarting network (via systemctl): Job for network.service canceled.
[FAILED]

systemctl restart network
Job for network.service canceled.

If cyberpanel server network is down (venet0: mtu 1500 qdisc noop state DOWN) after server reboot, make sure:

vi /etc/fstab
#/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0
#/tmp /var/tmp none bind 0 0

service network restart
Restarting network (via systemctl):
[ OK ]

monitor and block syn flood

Can help prevent SYN flood DDoS attack

[Mon Nov 4 17:35:53 2019] possible SYN flooding on ctid 0, port 465. Sending cookies.
[Mon Nov 4 19:23:41 2019] possible SYN flooding on ctid 0, port 25. Sending cookies

cat > SYN_RECV.sh << "END"

#!/bin/bash
netstat -natp | grep SYN_RECV | sort | awk '{ print $5 }' | sort | cut -d ":" -f1 | uniq -c | awk '{if ($1>100) system("iptables -I INPUT -s "$2" -j REJECT")}'
END

#ANsible copy and add to cron:

ansible -i inv.txt cpa -m copy -a "src=SYN_RECV.sh dest=/root/bin/SYN_RECV.sh mode=755 owner=root group=root"
ansible -i inv cpa -m cron -a "name=SYN_BLOCK job=/root/bin/SYN_RECV.sh user=root"

lxc-start: lxccontainer.c: wait_on_daemonized_start: 754 Received container state “STOPPING” instead of “RUNNING”

It could be cause by this libvirt error: libvirtd[18329]: Failed to open file ‘/sys/class/net/vethSUT3FA/operstate’: No such file or directory

Fix:
brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.525400a97813 yes virbr0-nic

vim /var/lib/lxc/my_server/config
lxc.network.link = virbr0

lxc-start -n my_server -d

pppd: LCP: timeout sending Config-Requests

Jan 17 04:52:57 cloudlix pppd[18873]: Connect: ppp0 <--> /dev/pts/1
Jan 17 04:53:27 cloudlix pppd[18873]: LCP: timeout sending Config-Requests
Jan 17 04:53:27 cloudlix pppd[18873]: Connection terminated.
Jan 17 04:53:27 cloudlix pppd[18873]: Modem hangup
Jan 17 04:53:27 cloudlix pppd[18873]: Exit.

This error means you local ot network firewall blocks GRE packets, so if you are using Fedora just do this:

sudo firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT
sudo firewall-cmd --permanent --direct --add-rule ipv6 filter INPUT 0 -p gre -j ACCEPT (if you are using IPV6)
sudo firewall-cmd --reload

Centos 6 pptp server on OpenVZ


yum list installed | grep ppt
ppp.x86_64 2.4.5-10.el6 @base
pptpd.x86_64 1.4.0-3.el6 @epel

cat /etc/pptpd.conf
option /etc/ppp/options.pptpd
logwtmp
connections 156
localip your_vpn_server_IP_address
remoteip 192.168.0.101-200

cat /etc/ppp/options.pptpd
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd

cat /etc/ppp/chap-secrets
vpn_username * your_client_password *

/etc/init.d/pptpd start

iptables:

-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -i ppp+ -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1723 -j ACCEPT
-A INPUT -p gre -j ACCEPT
-A OUTPUT -p gre -j ACCEPT

-P PREROUTING ACCEPT
-P POSTROUTING ACCEPT
-P OUTPUT ACCEPT
-A POSTROUTING -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/conf/venet0/proxy_arp
vi /etc/ppp/ip-up.local
ifconfig ppp0 mtu 1468

MPPE should be enabled on client side.


Jan 16 07:27:17 cloudlix pptpd[2616]: CTRL: Starting call (launching pppd, opening GRE)
Jan 16 07:27:17 cloudlix pppd[2617]: Plugin /usr/lib64/pptpd/pptpd-logwtmp.so loaded.
Jan 16 07:27:17 cloudlix pppd[2617]: pppd 2.4.5 started by root, uid 0
Jan 16 07:27:17 cloudlix pppd[2617]: Using interface ppp0
Jan 16 07:27:17 cloudlix pppd[2617]: Connect: ppp0 <--> /dev/pts/1
Jan 16 07:27:17 cloudlix pppd[2617]: peer from calling number XX.80.253.XX authorized
Jan 16 07:27:17 cloudlix pppd[2617]: MPPE 128-bit stateless compression enabled
Jan 16 07:27:17 cloudlix pppd[2617]: Cannot determine ethernet address for proxy ARP
Jan 16 07:27:17 cloudlix pppd[2617]: local IP address 5.199.XX.XX
Jan 16 07:27:17 cloudlix pppd[2617]: remote IP address 192.168.0.101
Jan 16 07:28:15 cloudlix pppd[2617]: Modem hangup
Jan 16 07:28:15 cloudlix pppd[2617]: Connect time 1.0 minutes.
Jan 16 07:28:15 cloudlix pppd[2617]: Sent 2200951 bytes, received 163549 bytes.
Jan 16 07:28:15 cloudlix pppd[2617]: MPPE disabled
Jan 16 07:28:15 cloudlix pppd[2617]: Connection terminated.
Jan 16 07:28:15 cloudlix pppd[2617]: Exit.
Jan 16 07:28:15 cloudlix pptpd[2616]: CTRL: Client XX.80.253.XX control connection finished