Hot answers tagged

5

Yes, you can. Using grep with PCRE(-P): ip addr | grep -Po '^\d+:\s+\K[^:]+' ^\d+:\s+ matched the portion before interface name at the start, \K discards the match [^:]+ gets the portion upto the next : i.e. the interface name Similar logic using sed: ip addr | sed -nE 's/^[[:digit:]]+:[[:blank:]]+([^:]+).*/\1/p' On my system: % ip addr | grep -Po ...


4

When you press Enter, the full command is already on the remote machine. There is no guarantee that this will not cause a disconnect but the reason it hasn't impacted your session so far is that the system didn't have time to notice the disconnection which actually happened. Processes which are receiving data while it gets disconnected will probably ...


3

Proper way of doing this is to put those commands in a simple shell script and executing this script, after transferring it to the remote machine, by a single remote ssh command rather than two commands on one line, separated by a semicolon. Normally, as Julie said, it is not something to worry about but it is not bullet-proof either. Also, consider, some ...


3

on each node, check: cat /proc/sys/net/ipv4/icmp_echo_ignore_all if it is 1, change to 0: echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all


3

Preserving your work, a possible solution could be: #!/bin/bash cd /home/prova for f in *; do basename $f '_firewall_rule' >> output.txt printf "\n" >> output.txt grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" "$f" | while read -r line ; do echo $line >> output.txt printf "\n" >> output.txt done done See optimization ...


2

You could do it all with awk in a single command if you don't have too many files for the command line to handle: awk --posix 'FNR==1 {f=FILENAME; sub("_firewall_rule", "", f); print f "\n"} /([0-9]{1,3}\.){3}[0-9]{1,3}/ {print $0 "\n"}' *_firewall_rule for my version of gawk I needed the --posix to get the braces to work right in the regex. How it works ...


2

find your_dir -name "*firewall_rule" -exec basename {} \; -exec echo \; -exec grep -P '(\d{1,3}\.){3}\d{1,3}' {} \; -exec echo \; > your_output_file This will (line by line): Find all files in your_dir ending in "firewall_rule" Output a blank line Output all [0-999].[0-999].[0-999].[0-999] IP addresses Output another blank line Send the output to a ...


2

The following command should give users the capability to use ping6. As root run setcap cap_net_raw+ep /usr/bin/ping


2

Unfortunately, that's just not going to work well—not because of the IP being on both interfaces, but because the subnet is. If your device needs to talk to 192.168.1.2, which interface should it send that traffic on? Maybe that's the customer's device trying to talk to your device, maybe it's your device trying to talk to one of your other devices. The ...


1

It would help to know the Unix or Unix-like O/S and version because software and file locations can differ. If I understand the problem, you want each machine to have WAN access using eth0 and LAN access using eth1. For any Linux, make a new routing table for eth1, naming the network "mgmt", or whichever name you like. echo '200 mgmt' >> /etc/...


1

Four interfaces(say eth1, eth2,eth3,eth4) are configured with different subnet IP addresses in my LINUX server, so does that mean are there four NIC cards in In my server?. Maybe. More likely on a server are that number of ports are on the main board. In servers dual and quad port cards are also common, so the number of NIC cards can be anywhere between ...



Only top voted, non community-wiki answers of a minimum length are eligible