FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
os:linux:net:index.html [2018/01/04 00:24] kurihara [Operation] |
os:linux:net:index.html [2019/02/11 00:40] (current) kurihara |
||
---|---|---|---|
Line 1: | Line 1: | ||
[[: | [[: | ||
- | ====== Network Configuration (net.py) ====== | + | ====== |
$FHHOME/ | $FHHOME/ | ||
Line 8: | Line 8: | ||
- | ===== Operation ===== | + | ===== Operation |
<sxh bash toolbar: | <sxh bash toolbar: | ||
- | $ fab -l |grep net | + | $ fab -l |grep -F net. |
</ | </ | ||
+ | |||
+ | |||
+ | \\ | ||
+ | ==== Fabric one-line Task Examples ==== | ||
<sxh bash toolbar: | <sxh bash toolbar: | ||
Line 18: | Line 22: | ||
# Interface' | # Interface' | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- "ip a |grep inet" |
# Bonding | # Bonding | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- egrep " |
+ | $ fab -H $H | ||
+ | |||
+ | # Bonding Driver | ||
+ | $ fab -H $H -- "lsmod |grep bonding" | ||
# NIC Driver | # NIC Driver | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- for i in `ip a |grep mtu |awk -F: {' |
# Routing | # Routing | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- netstat -rn |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- cat / |
# nmap | # nmap | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- sudo nmap -Pn -sT -p 22 xx.xx.xx.xx |
# tcpdump | # tcpdump | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- sudo tcpdump |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- sudo tcpdump -n not arp and not port 123 and not port 22 -W1 -G30 # check 30 seconds |
# DNS | # DNS | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- cat / |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- host google.com |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- host test-server-01 |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- host x.x.x.x |
</ | </ | ||
Line 55: | Line 63: | ||
from fabric.api import * | from fabric.api import * | ||
from fabric.contrib import files | from fabric.contrib import files | ||
+ | from datetime import datetime | ||
FHHOME=os.environ[" | FHHOME=os.environ[" | ||
Line 64: | Line 73: | ||
run(" | run(" | ||
# RHEL/CentOS | # RHEL/CentOS | ||
- | run("/usr/bin/cp -f / | + | run(" |
# Debian/ | # Debian/ | ||
- | run("/usr/bin/cp -f / | + | run(" |
- | run("/usr/bin/cp -f / | + | run(" |
Line 74: | Line 83: | ||
def set_bond(ip, | def set_bond(ip, | ||
backup_config() | backup_config() | ||
+ | date = datetime.now().strftime(' | ||
# put | # put | ||
- | put(" | + | put(" |
- | put(" | + | put(" |
- | put(" | + | put(" |
# bond | # bond | ||
- | sed("/etc/ | + | sed("/tmp/ifcfg-%s.%s" |
- | sed("/etc/ | + | sed("/tmp/ifcfg-%s.%s" |
# nic1 | # nic1 | ||
- | sed("/etc/ | + | sed("/tmp/ifcfg-%s.%s" |
- | sed("/etc/ | + | sed("/tmp/ifcfg-%s.%s" |
# nic2 | # nic2 | ||
- | sed("/etc/ | + | sed("/tmp/ifcfg-%s.%s" |
- | | + | sed("/ |
+ | |||
+ | run(" | ||
+ | run(" | ||
+ | run(" | ||
+ | |||
+ | | ||
+ | sudo("mv / | ||
+ | sudo("mv / | ||
+ | |||
</ | </ | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.