I would like to find a way to grab the assigned IPv4 and IPv6 addresses to different interfaces and being able to determine which interface they're tied to.
Currently I am looping ' System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces ' and able to grab interface specific information:
For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
myarr(count2, 0) = (String.Format("{0}", nic.Description))
myarr(count2, 1) = (String.Format("{0}", nic.GetPhysicalAddress))
myarr(count2, 2) = (String.Format("{0}", nic.OperationalStatus))
myarr(count2, 3) = (String.Format("{0}", nic.Speed))
count2 += 1
Next
Through this method I can't determine a simple method to grab assigned IP Addresses unfortunately.
The most common method that I can easily find with google-foo is to find your IP via going through something like the following:
Dim ipAdd As IPAddress = Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.First(Function(f) f.AddressFamily = Sockets.AddressFamily.InterNetwork)
Which is fine and dandy but I can't determine which interface is being used nor can it determine an assigned IP Address that's not going through DNS or mulitple NICS.
I can possibly do some ghetto method of issuing a command-line command and parsing all the information out of ipconfig or getting a GUID and running through the registry but I feel like there should be an easier more effecient method.
A good example of what I want is the ability to produce a list like IPCONFIG where it has interface information and their designated IP Addresess, etc...
in you for-loop try
Dim ip = nic.GetIPProperties().UnicastAddresses(0).Address;
Related
I think my choice of words is correct. I want to take a group of switches and compile a list of Ip addresses and specific interfaces to have netmiko push commands to. For instance, scan all cisco switches and put together a list of all interfaces in vlan X and not being used. Can someone point me in the right direction of how to do this?
Sounds like you need to figure out the different steps to work out your solution.
Maybe something this:
Connect to switch
run show commands
config interface to vlan xx
I don't see any code or anything you have attempted so far but here is a simple flow for looping through a list of IP addresses.
#Python 3.7
from netmiko import ConnectionHandler
username = "user"
password = "password"
for ip in IPlist:
# netmiko code profiles;
cisco ={
"host":IP,
"username":username,
"password":password,
"device_type: "cisco_ios"
}
with ConnectHandler(**cisco) as ssh_conn:
print(sshcon.find_prompt())
# do stuff here.
I am developing an app that needs to get from a user a server name or address and a db name and build a folder structure based on that. The problem is that in order to have the same folder for all the different ways there are to get the path to the instance (localhost, ip address, etc.) i'm running the following Query:
select cast(SERVERPROPERTY('MachineName')as varchar)+'\'+##servicename
on the target server and set my folder structure based on that, and in that format saves the connection that the user gave (doesn't matter if i got ip or a server name, there is one connection string for all).
My problem is that when the instance is the default instance on the target machine, I cant seem to connect using MACHINE_NAME\MSSQLSERVER. I can only log in using the machine without instance name. So I need to either find a way to connect to the instance using its full name (preferred) or to find a way figure out if the targeted instance is the default one.
Any help would be very appreciated.
'MSSQLSERVER' is reserved for default instance, so you can
SELECT CAST(SERVERPROPERTY('MachineName')AS VARCHAR)+ CASE WHEN CHARINDEX('MSSQLSERVER', ##SERVICENAME, 1) >0 THEN '' ELSE '\'+##SERVICENAME END
I am working with Cisco Prime Infrastructure and need to create a CLI template for mass deployment to some switches. Prime uses Apache Velocity for its CLI content to script. I have run into a problem where I am running some code that loops through the VLANS on a switch and performs action per VLAN. The code works fine if the switch has multiple VLANS, but fails if it only has one. Example:
Switch1 consists of Vlan 1, so the array looks like this [Vlan1]
Switch2 consists of Vlan 1, Vlan 2, Vlan 3, array looks like [Vlan1, Vlan2, Vlan3]
The code:
#foreach($vlan in $VlanName)
interface $vlan
no ip helper-address
#end
$VlanName is defined in the Prime Database and returns the array of vlans on each switch. The above will work on Switch2 but will fail on Switch1. Is there a way in Apache Velocity to do a check to see if the array holds more than a single value? I would like to do an IF statement that changes the code to something like this:
#if ($VlanName.count = 1)
interface $VlanName
no ip helper-address
#else
#foreach($vlan in $VlanName)
interface $vlan
no ip helper-address
#end
Is this possible in Velocity?
You can always get the size by using invoking the size() method on the object.
#set($size = $VlanName.size())
#if($size == 1)
Only one
#end
I am trying to build a custom IP peripheral (my_perph). I have used the CIP tool to generate the basic perph and now want to add my custom external port (my_port).
Basically I followed this tutorial http://www.programmableplanet.com/author.asp?section_id=2142&doc_id=264841.
I have added the external port definitions to the top source vhdl my_perph.vhdl .
i.e
Port(
---Add user defined ports here----
MY_PORT : out std_logic;
I then added the port to the MPD file with the syntax:
PORT MY_PORT = "", DIR = O, IO_IF = MY_PORT_0, IO_IS = MY_PORT
This didn't work so I tried losing the 0 to match the name of the VHDL declared port so:
PORT MY_PORT = "", DIR = O, IO_IF = MY_PORT, IO_IS = MY_PORT
The issue is that once I have re-scanned the IP library I get the error saying there is
NO IO_INTERFACE MATCHING MY_PORT
It seems that my custom external port MY_PORT is not being recognised in the IP design although it exists in the HDL of the included IP entity.
And even when I go to add the perph I find that this port does not show up in the info. I am totally lost as I have followed all tutorials and tired every possible thing I can think of!
Read the Platform Specification Format guide. You need to understand all of the MPD file, before just copy and pasting lines within it. The line you have needs to have a matching IO_INTERFACE section (as the error message tells you)
If your IO is not part of a "standard" IO port (see the IO_INTERFACE section of the PSF) you should be able to use simply:
PORT MY_PORT = "", DIR = O
This is my first post to this precious website. I am a new learner of vb.net. I am working on a simple purchase project, where i got some errors. But the first thing is which baffled me is:
This is my connection string at module level, on the developed machine.
Public strCn As String = "Data Source = (local); Initial Catalog = PSys; Integrated Security = false; User ID = sa; Password = 123;"
Is it mandatory that Data Source must be the original name of the System Name. I mean If i use (local) or using ( . ), so will it work or not? Because when i copy my project to any other system for further development so every time i need to change the Data source, otherwise i get the error that: "Network-related or instance-specific error occurred......."
Kindly guide me that what i need to do.
When you are developing an application which uses a database server such as MsSQL it is not wise to install the server along with your application in every pc which is installed to. For example what are you going to do if a customer has a local network with 10 computers? Are you going to install SQL server in all 10 of them? And if so what if they need to share data?
So your best approach (based on common practice by other applications) will be to allow the user to install the SQL server where he wants and let him configure your application and point it to the server's location. If you follow that path then the configuration of your application can be in the setup application or in the application itself.
Now about the development phase, I had a similar situation in which I needed to develop the same application in two different computers. What I did was to install the SQL server in both of them with a named instance "sqlexpress" then in the application I used the
Data.SqlClient.SqlConnectionStringBuilder
class to build the connection string. I did something like this:
Public Function getDevConnectionString() As String
Dim csb As New Data.SqlClient.SqlConnectionStringBuilder(My.Settings.dbConnectionString) '<-My original cs in app settings
csb.DataSource = My.Computer.Name & "\sqlexpress"
Return csb.ConnectionString
End Function
Whenever I need a connection string I simply call getDevConnectionString() which returns the connection string based on the computer name plus the sql server instance name. For example:
Dim cs As String
#If DEBUG Then
cs = getDevConnectionString()
#Else
cs = getReleaseConnectionString()
#End If
where getReleaseConnectionString() is the function that returns your connection string configured by the customer.
Hope this point you the right direction...