In my virtual box there are four interfaces and loopback interface are present as below. eth0, eth1, eth2,eth3, lo.
VirtualBox:~/pysnmp# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:e1:eb:b9 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:10:b8:4b brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:94:00:83 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:62:2b:9f brd ff:ff:ff:ff:ff:ff
When i am trying to get the interfaces info using pysnmp nextcmd, it always shows only two interfaces eth0, lo.
Using this example:
http://snmplabs.com/pysnmp/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.html#fetch-scalar-and-table-variables
from pysnmp.hlapi import *
for (errorIndication,
errorStatus,
errorIndex,
varBinds) in nextCmd(SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget(('demo.snmplabs.com', 161)),
ContextData(),
ObjectType(ObjectIdentity('IF-MIB', 'ifDescr')),
ObjectType(ObjectIdentity('IF-MIB', 'ifType')),
ObjectType(ObjectIdentity('IF-MIB', 'ifMtu')),
ObjectType(ObjectIdentity('IF-MIB', 'ifSpeed')),
ObjectType(ObjectIdentity('IF-MIB', 'ifPhysAddress')),
ObjectType(ObjectIdentity('IF-MIB', 'ifType')),
lexicographicMode=False):
if errorIndication:
print(errorIndication)
break
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex)-1][0] or '?'))
break
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
Output:
root#VirtualBox:~/pysnmp# python tutorial.py
IF-MIB::ifDescr.1 = lo
IF-MIB::ifType.1 = softwareLoopback
IF-MIB::ifMtu.1 = 16436
IF-MIB::ifSpeed.1 = 10000000
IF-MIB::ifPhysAddress.1 =
IF-MIB::ifType.1 = softwareLoopback
IF-MIB::ifDescr.2 = eth0
IF-MIB::ifType.2 = ethernetCsmacd
IF-MIB::ifMtu.2 = 1500
IF-MIB::ifSpeed.2 = 100000000
IF-MIB::ifPhysAddress.2 = 00:12:79:62:f9:40
IF-MIB::ifType.2 = ethernetCsmacd
How about the remaining interfaces? It is not been displayed? Any ideas?
To fetch the interfaces in your local machine(virtual box), Modify the logic as below.
CommunityData('public', mpModel=0), < "Community string is what you configured in your local machine refer snmd.conf file">
UdpTransportTarget(('localhost', 161)). <Target IP address is our local host>
UdpTransportTarget(('demo.snmplabs.com', 161)). The target IP address is demo.snmplabs.com. It is fetching the interface names from this IP address.
Related
I setup minikube on MacOS and as result there is a virtual intf created on the host machine as the following:
bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
options=3<RXCSUM,TXCSUM>
ether f2:18:98:52:ec:64
inet 192.168.64.1 netmask 0xffffff00 broadcast 192.168.64.255
inet6 fe80::f018:98ff:fe52:ec64%bridge100 prefixlen 64 scopeid 0x13
inet6 fdd5:e29:6049:e016:475:5258:18a3:3700 prefixlen 64 autoconf secured
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x0
member: vmenet0 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 18 priority 0 path cost 0
member: vmenet1 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 20 priority 0 path cost 0
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
On a minikube VM, I got an error when trying to pull a image when I run a VPN on the host machine:
$ docker run -it --net=container:$ID --pid=container:$ID --volumes-from=$ID alpine sh
Unable to find image 'alpine:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 192.168.64.1:53: read udp 192.168.64.19:59651->192.168.64.1:53: i/o timeout.
If I do a dig on host when the VPN is running, I got the following outputs showing dns with 192.168.64.1 fails.
(base) /etc $ dig registry-1.docker.io
; <<>> DiG 9.10.6 <<>> registry-1.docker.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45428
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 3591 IN A 52.205.127.201
registry-1.docker.io. 3591 IN A 34.237.244.67
registry-1.docker.io. 3591 IN A 52.55.124.246
registry-1.docker.io. 3591 IN A 52.72.252.48
registry-1.docker.io. 3591 IN A 34.203.135.183
registry-1.docker.io. 3591 IN A 52.202.132.224
registry-1.docker.io. 3591 IN A 54.86.228.181
registry-1.docker.io. 3591 IN A 54.197.112.205
;; Query time: 347 msec
;; SERVER: 10.44.0.1#53(10.44.0.1)
;; WHEN: Wed Mar 02 17:25:26 CST 2022
;; MSG SIZE rcvd: 177
(base) /etc $ dig registry-1.docker.io #192.168.64.1
; <<>> DiG 9.10.6 <<>> registry-1.docker.io #192.168.64.1
;; global options: +cmd
;; connection timed out; no servers could be reached
(base) /etc $
If I stop the VPN and do a dig on the host, I got the following outputs showing dns with 192.168.64.1 success.
(base) /etc $ dig registry-1.docker.io
; <<>> DiG 9.10.6 <<>> registry-1.docker.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39523
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 4, ADDITIONAL: 7
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 600 IN A 54.86.228.181
registry-1.docker.io. 600 IN A 52.72.252.48
registry-1.docker.io. 600 IN A 174.129.220.74
registry-1.docker.io. 600 IN A 34.237.244.67
registry-1.docker.io. 600 IN A 52.205.127.201
registry-1.docker.io. 600 IN A 52.202.132.224
registry-1.docker.io. 600 IN A 52.200.37.142
registry-1.docker.io. 600 IN A 52.203.238.92
;; AUTHORITY SECTION:
docker.io. 2920 IN NS ns-1168.awsdns-18.org.
docker.io. 2920 IN NS ns-513.awsdns-00.net.
docker.io. 2920 IN NS ns-1827.awsdns-36.co.uk.
docker.io. 2920 IN NS ns-421.awsdns-52.com.
;; ADDITIONAL SECTION:
ns-1168.awsdns-18.org. 143919 IN A 205.251.196.144
ns-421.awsdns-52.com. 170410 IN A 205.251.193.165
ns-513.awsdns-00.net. 132154 IN A 205.251.194.1
ns-1168.awsdns-18.org. 143919 IN AAAA 2600:9000:5304:9000::1
ns-1827.awsdns-36.co.uk. 171777 IN AAAA 2600:9000:5307:2300::1
ns-421.awsdns-52.com. 172051 IN AAAA 2600:9000:5301:a500::1
ns-513.awsdns-00.net. 132154 IN AAAA 2600:9000:5302:100::1
;; Query time: 6 msec
;; SERVER: 202.96.134.133#53(202.96.134.133)
;; WHEN: Wed Mar 02 17:25:56 CST 2022
;; MSG SIZE rcvd: 466
(base) /etc $ dig registry-1.docker.io #192.168.64.1
; <<>> DiG 9.10.6 <<>> registry-1.docker.io #192.168.64.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21844
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 752 IN A 52.72.252.48
registry-1.docker.io. 752 IN A 174.129.220.74
registry-1.docker.io. 752 IN A 34.237.244.67
registry-1.docker.io. 752 IN A 52.205.127.201
registry-1.docker.io. 752 IN A 52.202.132.224
registry-1.docker.io. 752 IN A 52.200.37.142
registry-1.docker.io. 752 IN A 52.203.238.92
registry-1.docker.io. 752 IN A 54.86.228.181
;; Query time: 3 msec
;; SERVER: 192.168.64.1#53(192.168.64.1)
;; WHEN: Wed Mar 02 17:25:59 CST 2022
;; MSG SIZE rcvd: 177
Why such behavior of DNS resolution with respect to VPN? How to make the DNS work when VPN is running?
When you connect to a VPN all your traffic is routed via VPN tunnel and it can't reach 192.168.64.1 since the router in at the other VPN end doesn't know where this address is:
; <<>> DiG 9.10.6 <<>> registry-1.docker.io #192.168.64.1
;; connection timed out; no servers could be reached
This is an expected behavior so you need to set up a route to 192.168.64.0 so it doesn't end up in a VPN tunnel.
You can read how to do this here and here.
Most simple one will look like: route add -host 192.168.64.1 my.local.gateway.ip which adds a route to 54.81.143.201 via specific gateway my.local.gateway.ip.
I am looking for a Powershell command that disables DHCP and sets the machine's private IP as a static IP; basically, I'm looking for the Powershell equivalent of following actions in the UI.
Control panel -> Network and Sharing Center -> Ethernet -> Properties -> IPv4 -> Properties -> toggle off "Obtain an IP address automatically" and toggle on "Use the following IP address" -> fill out IPv4 address, default gateway, and subnet mask.
The following commands, taken from this guide, seems to describe what I'm after, but Remove-NetIPAddress results in kicking me off the server and locking me out.
$IP = "10.10.10.10"
$MaskBits = 24 # This means subnet mask = 255.255.255.0
$Gateway = "10.10.10.1"
$Dns = "10.10.10.100"
$IPType = "IPv4"
# Retrieve the network adapter that you want to configure
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}
# Remove any existing IP, gateway from our ipv4 adapter
If (($adapter | Get-NetIPConfiguration).IPv4Address.IPAddress) {
$adapter | Remove-NetIPAddress -AddressFamily $IPType -Confirm:$false
}
If (($adapter | Get-NetIPConfiguration).Ipv4DefaultGateway) {
$adapter | Remove-NetRoute -AddressFamily $IPType -Confirm:$false
}
# Configure the IP address and default gateway
$adapter | New-NetIPAddress `
-AddressFamily $IPType `
-IPAddress $IP `
-PrefixLength $MaskBits `
-DefaultGateway $Gateway
I'm unable to create a new IPv4 address so long as the existing one is still around, but removing the existing one borks the connection to the server.
That is incorrect. You can set multiple IPs on the same interface. So you simply add the new one with New-NetIPAddress and then remove the previous one.
$currentIP = Get-NetIPAddress | where ipaddress -eq '192.168.43.96'
New-NetIPAddress -InterfaceAlias $currentIP.InterfaceAlias -IPAddress 192.168.43.20 -PrefixLength 24
Remove-NetIPAddress -InterfaceAlias $currentIP.InterfaceAlias -IPAddress $currentIP.IPAddress
The DNS and Gateway are separate things. Just don't change those if you don't need to. To avoid the confirmation prompt, simply add -Confirm:$false to the Remove-NetIPAddress command.
I'm trying to configure 3proxy server using this guide (I've already used it on OHV hosting and it works just nice!), now trying to start 3proxy behind NAT, and have error 12 of 3proxy which means 12 - failed to bind()
Where is mistake and what I'm doing wrong?
Internal IP:
172.16.20.50
External IP:
82.118.227.155
NAT Ports:
5001-5020
Here are my entire config:
######################
##3Proxy.cfg Content##
######################
##Main##
#Starting 3proxy as a service/daemon
daemon
#DNS Servers to resolve domains and for the local DNS cache
#that providers faster resolution for cached entries
nserver 8.8.8.8
nserver 1.1.1.1
nscache 65536
#Authentication
#CL = Clear Text, CR = Encrypted Passswords (MD5)
#Add MD5 users with MD5 passwords with "" (see below)
#users "user:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49."
users 3proxy:CL:hidden
#Logging
log /var/log/3proxy/3proxy.log D
logformat "- +_L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
#logformat "-""+_L%C - %U [%d/%o/%Y:%H:%M:%S %z] ""%T"" %E %I"
rotate 30
#Auth type
#auth strong = username & password
auth strong
#Binding address
external 82.118.227.155
internal 172.16.20.50
#SOCKS5
auth strong
flush
allow 3proxy
maxconn 1000
socks -p5011
User 3proxy created, access to 3proxy granted.
Logs, which means connection established, but no traffic transfered (0/0):
[root#bgvpn113 ~]# tail -f /var/log/3proxy/3proxy.log.2018.05.14
1526329023.448 SOCK5.5011 00012 3proxy MY_LOCAL_IP:21151 88.212.201.205:443 0 0 0 CONNECT_88.212.201.205:443
1526329023.458 SOCK5.5011 00012 3proxy MY_LOCAL_IP:21154 88.212.201.205:443 0 0 0 CONNECT_88.212.201.205:443
1526329023.698 SOCK5.5011 00012 3proxy MY_LOCAL_IP:21158 88.212.201.205:443 0 0 0 CONNECT_88.212.201.205:443
1526329037.419 SOCK5.5011 00012 3proxy MY_LOCAL_IP:21162 195.201.201.32:443 0 0 0 CONNECT_195.201.201.32:443
1526329037.669 SOCK5.5011 00012 3proxy MY_LOCAL_IP:21164 195.201.201.32:443 0 0 0 CONNECT_195.201.201.32:443
Mistake was in outside IP.
I set both ips to 172.16.20.50 and it started to work!
I ran Vagrant/VirtualBox on my MacBook Pro
OS: Yosemite 10.10.5
Model Identifier: MacBookPro11,1
Processor Name: Intel Core i5
Processor Speed: 2.4 GHz
Memory: 8 GB
After few requests it stops responding and I can't even halt it or ctrl + c it via terminal. All I can do is go to VirtualBox and to shut down it.
Installed versions:
Vagrant 1.7.4
VirtualBox 5.0.4
grunt-cli v0.1.13
grunt v0.4.5
Vagrantfile:
$ProjectName = 'projectdev'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_url = "https://atlas.hashicorp.com/ubuntu/boxes/trusty64"
config.vm.hostname = "#{$ProjectName}"
config.vm.network "forwarded_port", guest: 80, host: 8888
config.vm.network "forwarded_port", guest: 5432, host: 15432
config.vm.network :private_network, ip: "10.0.0.10"
config.vm.synced_folder ".", "/vagrant"
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
#config.vm.provider "virtualbox" do |v|
#v.gui = true
#end
config.vm.provision :shell, path: "infra/bootstrap.sh"
end
Vagrant::Config.run do |config|
#config.vm.share_folder "bootstrap", "/mnt/bootstrap", ".", :create => true
config.vm.provision :shell, :path => "infra/postgresql.sh"
# PostgreSQL Server port forwarding
#config.vm.forward_port 5432, 15432
end
Thats how top looked at the moments its stopped responding
top - 18:58:37 up 3 min, 2 users, load average: 3.55, 1.31, 0.48
Tasks: 140 total, 2 running, 138 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.6 us, 74.3 sy, 0.0 ni, 22.9 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
KiB Mem: 2049900 total, 930712 used, 1119188 free, 19608 buffers
KiB Swap: 0 total, 0 used, 0 free. 170280 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1784 vagrant 20 0 756756 104628 7476 R 150.7 5.1 2:09.88 grunt
32 root 20 0 0 0 0 S 0.3 0.0 0:00.14 kworker/0:1
1921 vagrant 20 0 107696 2184 1180 S 0.3 0.1 0:00.06 sshd
1936 vagrant 20 0 23692 1700 1168 R 0.3 0.1 0:00.11 top
1 root 20 0 33640 2996 1492 S 0.0 0.1 0:01.26 init
Is there anything to be done for Grunt to take less resources and not kill my VM ?
So seems I found an answer to my problem!
On MACs you should turn NFS SYNCED FOLDERS on
Use all CPU cores
Don't skimp on memmory for Virtual Machine ;)
Also, I haven't tried this yet, but may be also a good optimisation!
grunt-watch-slow
I trying to use the Vagrant VMWare Fusion Plugin, however (whatever I do) to set a static IP address on my private VMWare network the VM only ever gets a DHCP address.
I’ve added this to my Vagrant config file:
server1.vm.network "private_network", ip: "192.168.13.120"
However, it just gets ignored and a dynamic DHCP address is issued. I’m using the hashicorp/precise64 base image.
Here’s a complete listing of the Vagrant file I'm using to test.
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64_vmware.box"
# Turn off shared folders
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
# Begin server1
config.vm.define "server1" do |server1|
server1.vm.hostname = "server1"
server1.vm.provider "vmware_fusion" do |v|
v.vmx["numvcpus"] = "1"
v.vmx["memsize"] = "512"
end
server1.vm.provider "virtualbox" do |v|
v.customize [ "modifyvm", :id, "--cpus", "1" ]
v.customize [ "modifyvm", :id, "--memory", "512" ]
end
server1.vm.network "private_network", ip: "192.168.13.120"
end
# End server1
....................................
end
And this is how my VMWare private interface is configured:
vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:08
inet 192.168.13.1 netmask 0xffffff00 broadcast 192.168.13.255
Edit /Library/Preferences/VMware\ Fusion/networking and disable DHCP for the adapter that the IP belongs to.
For example:
...
answer VNET_2_DHCP no
answer VNET_2_HOSTONLY_NETMASK 255.255.255.0
answer VNET_2_HOSTONLY_SUBNET 172.17.8.0
answer VNET_2_VIRTUAL_ADAPTER yes
...
And then restart VMware Fusion networking
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —stop
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —configure
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —start
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —status
My use case:
This helped in my situation which is pretty much the same as yours.
server.vm.network :private_network, ip: 172.17.8.100
With DHCP on I had something like:
inet 172.17.8.131/24 brd 172.17.8.255 scope global dynamic enp0s18
After turning DHCP off, vm is assigned the defined private IP address:
inet 172.17.8.100/24 brd 172.17.8.255 scope global enp0s18
Let me know how it goes.